60 627
Assignments Done
97,8%
Successfully Done
In April 2018

Answer to Question #53470 in C for rajashree g.s.

Question #53470
#include<stdio.h>
int main()
{
int k=35;
printf("\n %d %d %d",k==35,k=50,k>40);
return 0;
}
please explain the logic behind this program very clearly sir and give the output
Expert's answer
Solve
Output:

0 50 0
Explain:
Output executing from right to left
Since 35<40, we have false value and as integer this expression have value 0
In printf exist assignment to k, it execute first. So, at printf value of k is 50.
Since k=50, second output – is output k, so, we have 50
Since 50≠35, we have false value and as integer this is expression have value 0

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
03.02.16, 17:30

It is compiler-dependent, for example, in GCC the result is
0 50 0.
First, it prints result of comparison k > 40: but k equals 35 and answer is false, converted to int, 0.
Second, assignment k = 50, and result is printed.
Third, comparison k == 35 is printed: but k equals 50 and answer is false, converted to int, 0.

heena
31.01.16, 21:37

int k=35;
printf("\n %d %d %d",k==35,k=50,k>40);
y the output is executing from right to left
want u to please explain its solution

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions