If switch feature is used, then
A. | default case must be present |
B. | default case, if used, should be the last case |
C. | default case, if used, can be placed anywhere |
D. | none of the above |
Option: C Explanation : Click on Discuss to view users comments. |
The switch feature
A. | can always be replaced by a nested it-then-else clause |
B. | enhances logical clarity |
C. | can't always be replaced by a nested if -then-else clause |
D. | Both (a) and (b) |
Option: D Explanation : Click on Discuss to view users comments. |
Break statement can be simulated by using
A. | goto |
B. | return |
C. | exit |
D. | any of the above features |
Option: A Explanation : Click on Discuss to view users comments. |
The following program fragment
if (2 < 1)
;
else
x = (2 < 0) ? printf("one") : printf("four");
printf ("%d", x);
A. | prints nothing |
B. | results in a syntax error |
C. | prints four 0 |
D. | none of the above |
Option: D Explanation : here else clause will be executed . Since 2 < 0 is false , 4 will be printed Click on Discuss to view users comments. |
Consider the following program fragment
if (a>b)
printf("a>b");
else
printf("else part");
printf("a<=b");
a<=b will be printed if
A. | a>b |
B. | a<b |
C. | a==b |
D. | Both (b) and (c) |
Option: D Explanation : The else clause has no brackets i.e., { and }. This means the else clause is made up of only one statement. So, printf( " a < = b" ) will be executed anyway, i.e. if a > b or a <= b. Hence the answer. Click on Discuss to view users comments. |