In: Computer Science
Assume i = 4, j = 9, k = 5 and m = -3. What does each of the following statements print?
a) printf("%d", i == 4);
b) printf("%d", j!= 3);
c) printf("%d", i >= 5 && j < 2);
d) printf("%d", !m || k > m);
e) printf("%d", !k && m);
f) printf("%d", k - m < j || 5 - j >= k);
g) printf("%d", j + m <= i && !0);
h) printf("%d", !(j + m)); i) printf("%d", !(k < m)); j) printf("%d", !(j < k));
i = 4, j = 9, k = 5 and m = -3.
printf("%d", i == 4);
Yes. i==4
Ans:1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
printf("%d", j!= 3);
i is not equal to 3. True
Ans:1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
printf("%d", i >= 5 && j < 2);
i>=5 ==>False
j<2==>False
0 && 0 =0
ANs:0
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
printf("%d", !m || k > m);
m is a non zero number. Hence !m is 0.
k>m is true.
0||1=1
Ans:1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
printf("%d", !k && m);
k is a non zero number .!k is 0
m is also a non zero number
Hence k&&m is 0 && 1==>0
ANs: 0
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
printf("%d", k - m < j || 5 - j >= k);
k-m=5+3=8 ; 8<j (true)
5-j=5-9=4;4>=k (true)
true|| true==>true(1)
Ans:1
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
printf("%d", j + m <= i && !0);
j+m=9-3=6; 6<=i (No- False)
!0==>true
true && false==>false(0)
Ans:0
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
printf("%d", !(j + m));
j+m=9-3=6
Its non zero number. Hence !1= 0
Ans:0
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
printf("%d", !(k < m));
k<m is false.
!(false)==> True
Ans:1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
printf("%d", !(j < k));
j<k is false;
!(fasle)==>true
Ans:1