I can't get this function to output the desired value of 0.07.
#include <stdio.h>
#include <cs50.h>
#include <math.h>
float i = 1.32;
float quar_val = 0.25;
int func(float val, float input)
{
while (val < input)
{
input = input - val;
printf("loop: %.02f\n", input);
}
printf("end loop: %.02f\n", input);
return input;
}
int main(void)
{
float x = func(quar_val, i);
printf("end: %.02f\n", x);
}
here's the output i get:
loop: 1.07
loop: 0.82
loop: 0.57
loop: 0.32
loop: 0.07
end loop: 0.07
end: 0.00