I made a program that can get the largest integral of a float value:
#include <stdio.h>
float get_value(float a);
int main() {
float num = 4.58;
float new_val = get_value(num);
printf("%f \n", new_val);
}
float get_value(float a) {
int c = a;
for (int i = 0; i < 99; i++) {
a -= 0.01;
if (a == c) {
break;
}
}
return a;
}
It didn't work in the way I wanted it to be, so I want a shorthand of it instead of making a function.
So is there a function that I can use for this?