#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.
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!
Learn more about our help with Assignments:
C