Q. What is the output of the following C program?
Code:#include <stdio.h>
int main()
{
float a = 0.1;
if (a == 0.1f)
printf("equal\n");
else
printf("not equal\n");
}
β
Correct Answer: (A)
equal
Explanation: To check the equality of a float number you have to follow the value with the f letter. The output is as follows:
$gcc prog2.c
$ a.out
equal
$gcc prog2.c
$ a.out
equal