Conditional Statement


Q11.

Consider the following code segment: for (int k=0; k<20; k=k+2) { if (k % 3 == 1) system.out.print(k+ " "); } What is printed as a result of executing the code segment?
GateOverflow

Q12.

Consider the following segment of C-code:int j, n; j = 1; while (j <= n) j = j * 2;The number of comparisons made in the execution of the loop for any n>0 is:
GateOverflow

Q13.

An unrestricted use of the "go to" statement is harmful because of which of the following reason (s):
GateOverflow

Q14.

In the following Pascal program segment, what is the value of X after the execution of the program segment? X := -10; Y := 20; If X > Y then if X < 0 then X := abs(X) else X := 2*X;
GateOverflow

Q15.

An unrestricted use of the "goto" statement is harmful because
GateOverflow

Q16.

Consider the following program fragment if(a > b) if(b > c) s1; else s2;s2 will be executed if
GateOverflow

Q17.

Assume that X and Y are non-zero positive integers. What does the following Pascal program segment do? while X <> Y do if X > Y then X := X - Y else Y := Y - X; write(X);
GateOverflow

Q18.

What is the output of the following C code? #include < stdio.h > int main() { int index; for(index=1; index<=5; index++) { printf("%d", index); if (index==3) continue; } }
GateOverflow

Q19.

Consider the following C program: #include < stdio.h > int main( ) { int i, j, k = 0; j = 2 * 3 / 4 + 2.0 / 5 + 8 / 5; k -= --j; for(i = 0; i < 5; i++) { switch(i + k) { case 1: case 2: printf("n%d", i+k); case 3: printf("n%d", i+k); default: printf("n%d", i+k); } } return 0; } The number of times printf statement is executed is ________.
GateOverflow

Q20.

What will be the output of the following C code? #include < stdio.h > main() { int i; for(i=0;i<5;i++) { int i=10; printf("%d" , i); i++; } return 0; }
GateOverflow