#include <stdio.h>
int main(){
float a;
printf("Enter Real Number: ");
scanf("%f", &a);
int b;
b=a*0.393701/12;
float c;
c=a*0.393701%12;
printf("b, c");
return 0;
}
Gives the error
10|error: invalid operands of types 'float' and 'double(double, double)' to binary 'operator*'|
10|error: expected ';' before 'of'|
Can someone point out the error please?
You can use the modulo operator %
only on integer types ( char
, short
, int
, long
, etc).
Also, you probably want to change printf("b, c")
to printf("%d, %f",b,c)
.
模运算符不对浮点运算
If you want to find out modulo of two floating point numbers then use fmod(real_number,real_number);
example:-
fmod(5.5,1.3);
output : 0.300000
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.