EXPLAINED ANSWERS FOR IP MID-TERM MODEL QUESTIONS
(a) 1020
This answer will be given when we type the following code;
It will be printed in the terminal as follows;
(b)2010
This answer will be given when we type the follwing code;
(c)10
We already know the answer of this question is 10. 10 can be given in several ways. In the question we assume that the answer would be 1020. But it isn't. Look at the figures given below. I typed the given example in the vi editor.
The above answer will be given by the following code also;
(d)20
20 will be given by following code;
(e) run time error
This can't be correct, refer the answer (c)
For above question the answer is (d) 1. It's a little bit tricky but if you know the precedence order of the operators and arithmetic which are related to the C language it's very simple. First, they've set some values for the variables.
x=2
y=6
z=6
Then they've made a formula ; x = y == z
According to the precedence order, we have to calculate the value for y == z. As both of those variables have the same value, that gives 1 as the value of 'y'. If y = 5 and z = 7 , the answer will be 0.
Here, we have to put Boolean rules.
After that we have to calculate the value for x = y. As we got the answer for y , we have to assign that value to x. So, the answer for x will be '1'. According to the code, we are asked to display the value of 'x'.
- The typed code;













Comments
Post a Comment