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 );
}
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 );
}
Answer: Option D
Was this answer helpful ?
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