Sail E0 Webinar
Question

What is the output of the following program:
#include<stdio.h>
void main()
{
int i=2,j=3, k, l;
float a, b ;
k = i / j * j ;
l = j / i * i ;
a = i / j * j ;
b = j / i * i ;
printf("%d %d %f %f" , k, l, a, b );
}
Options:
A .  3 3 2 2
B .  3 3 0 2.000000
C .  3 2 0.000000 3.000000
D .  0 2 0.000000 2.000000
Answer: Option D

RHS is evaluated first and then the value is promoted to float, float
arithmetic is not used here as there is no variable on the RHS that is
float.
The Float is printed with decimal followed by 6 zeros.




Was this answer helpful ?

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers