As a beginner, I am working on a C program.
#include <stdio.h>
int main() {
int speed, limit_num;
printf("please input :\n");
scanf("%d %d", &speed, &limit_num);
if ((float)speed >= limit_num * 1.5)
{
printf("Exceed %.0f%%. License Revoked\n", (float)(speed - limit_num)/limit_num * 100);
}
else if ((float)speed >= (limit_num * 1.1))
{
printf("Exceed %.0f%%. Ticket 200\n", (float)(speed - limit_num)/limit_num * 100);
}
else
{
printf("OK!\n");
}
return 0;
}
if I input"110 100", the output is"OK".
But theoretically, I think it should be "Exceed 10%. Ticket 200" , because (float)speed means a float value, and the result of limit*1.1 means a float value.
I tried to add the following code
printf("%f, %f\n", (float)limit_num * 1.1, (limit_num *1.1));
And input "110 100", here is the output
110.000000, 110.000000
From this point of view, it does not solve my puzzle.
Hope can get help, thank you.