I was trying to run a program but it shows an error as:
Invalid binary operator float to int
When I tried making it float it says:
Invalid binary operator float to float
The problem is with % operator And its operands.
Please tell me what to do?
#include <stdio.h>
int main()
{
float x,y;
scanf("%f%f",&x,&y);
float z=x%5.0f;
if(x<=y && z==0)
printf("%.2f",y-x-0.50);
else if (x>y || z!=0)
printf("%.2f",y);
return 0;
}
Modulus % only makes sense with integers because it is defined as the remainder from integer division. You can't do integer division with floats.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With