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

Question #53468
#include<stdio.h> int main() { int k=35; printf("\n %d %d %d",k==35,k=50,k>40); return 0; } please sir explain the logic behind this program clearly.
Expert's answer
Code is executed as follows:
First the variable of type integer 'k' assigned the constant of 35
Second to the function 'printf' four parameters are passed. The first parameters is the string which state, what types of variables we want to display (formatting string). The remained three are the logic opperations that return result.
Command k==35 checks on equality the value of k and the constant 35. k=50, assigns value 50 to k and returns assigned value. The 'k>40' checks if k more than 40 and displays 1 if it satisfies the requirements.
The trick is in the fact that commants are executed from right to left, so the k>40 will be executed first, yielding the result of false ('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!


Assignment Expert
15.08.17, 17:32

Dear arpit,
please use panel for submitting new questions

11.08.17, 10:49

printf("%d %d %d ",x++,++x,x++);

//solve this and explain this if possible.

Assignment Expert
28.07.15, 18:16

Sear shivangi, please use panel for submitting new questions.

28.07.15, 15:05

main( )
int x = 10, y = 20 ;
if ( x == y ) ;
printf ( "\n%d %d", x, y ) ;

Assignment Expert
22.07.15, 19:47

Considering the expert's answer, the output will be:
0 50 0

rajashree g.s.
20.07.15, 12:38

int main()
int k=35;
printf("\n %d %d %d",k==35,k=50,k>40)
what is the output of this program sir. Here k is already assigned the value 35 know sir.please explain the logic sir.

Leave a comment

Ask Your question

New on Blog