Multiple choice technology programming languages

What is the output of the following program ? main() { float a=1.1; double b=1.1; if (a==b) printf("Hai"); else printf("Hello"); }

  1. Compilation error-Type mismatch

  2. Hai

  3. Hello

  4. Run time error

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The float constant 1.1 undergoes precision loss during conversion when assigned to the single-precision float a. The double b retains full double-precision representation. When compared, a is promoted to double, but because the precision values differ, the equality check fails and prints Hello.