-
Which of the following statements are correct about the program given below?
#include <stdio.h>
int main ( )
{
float x = 2.8, y = 2.88;
if (x = y)
printf ("x and y are equal\n");
else
printf ("x and y are not equal\n");
return 0;
}
-
- The output of the program would be "x and y are equal".
- The statement if (x = y) would report a compilation error.
- Floats cannot be compared using if.
- switch should be used to compare floats.
- Conditional operates should be used to compare floats.
Correct Option: A
There is a non zero assignment value inside "if" so, it if condition will be true hence The output of the program would be "x and y are equal".