A

Admin • 36.96K Points
Coach

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");
}
  • (A) equal
  • (B) not equal
  • (C) the output depends on the compiler
  • (D) None of the above

Explanation by: Admin
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

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.


Question analytics