Q. What will be the output of the following C code?
Code:
#include <stdio.h>
int main()
{
float x = 21.0;
x %= 3.0;
printf("%f",x);
return 0;
}
β
Correct Answer: (D)
Error
Explanation: In the above code, we are performing modulus operation with float values. Modulus operator doesn't work with float and double operands. Thus, the output will be:
error: invalid operands to binary % (have ‘float’ and ‘double’)