Multiple choice

What will be the output of following program code? #include<stdio.h> main() { int k; float j; j=9.0/2; k=9/2.0; printf(%dt%ft,k,j); j=9/2; k=9/2; printf(%dt%ft,k,j); k=9.0/2.0; j=2/9.0; printf(%dt%ft,k,j); }

  1. 4.000000 4.500000 4.000000 4 0.222222 4

  2. 4 4.500000 4 4.000000 0.222222 4

  3. 4 4.500000 4 4.000000 4 0.222222

  4. 4 4 4 4 4 0.000000

  5. None of these

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

k=9/2.0=4, as k is integer type output will be an integer. j=9.0/2=4.500000, as j is of type float the output will be in float. k=9/2=4, as k is integer type output will be an integer. j=9/2=4.000000 j=2/9.0=0.222222 k=9.0/2.0=4, as k is integer type output will be an integer.