Explore topic-wise MCQs in Control Instructions.

This section includes 94 Mcqs, each offering curated multiple-choice questions to sharpen your Control Instructions knowledge and support exam preparation. Choose a topic below to get started.

1.

When 1 is entered, The output of the code below is? #include void main() { int ch; printf("enter a value btw 1 to 2:"); scanf("%d", &ch); switch (ch, ch + 1) { case 1: printf("1 n"); break; case 2: printf("2"); break; } }

A. 1
B. 2
C. 3
D. Run time error
Answer» C. 3
2.

When 1 is entered, The output of the code below is? #include void main() { int ch; printf("enter a value btw 1 to 2:"); scanf("%d", &ch); switch (ch) { case 1: printf("1 n"); default: printf("2 n"); } }

A. 1
B. 2
C. 1 2
D. Run time error
Answer» D. Run time error
3.

When 2 is entered, The output of the code below is? #include void main() { int ch; printf("enter a value btw 1 to 2:"); scanf("%d", &ch); switch (ch) { case 1: printf("1 n"); break; printf("Hi"); default: printf("2 n"); } }

A. 1
B. Hi 2
C. Run time error
D. 2
Answer» E.
4.

The output of the code below is #include void main() { char *ch; printf("enter a value btw 1 to 3:"); scanf("%s", ch); switch (ch) { case "1": printf("1"); break; case "2": printf("2"); break; } }

A. 1
B. 2
C. Compile time error
D. No Compile time error
Answer» D. No Compile time error
5.

The output of the code below is #include void main() { double ch; printf("enter a value btw 1 to 2:"); scanf("%lf", &ch); switch (ch) { case 1: printf("1"); break; case 2: printf("2"); break; } }

A. Compile time error
B. 1
C. 2
D. Varies
Answer» B. 1
6.

The output of the code below is #include void main() { int x = 0; if (x == 0) printf("hi"); else printf("how are u"); printf("hello"); }

A. hi
B. how are you
C. hello
D. hihello
Answer» E.
7.

Comment on the following code below #include void main() { int x = 5; if (true); printf("hello"); }

A. It will display hello
B. It will throw an error
C. Nothing will be displayed
D. Compiler dependent
Answer» C. Nothing will be displayed
8.

The output of the code below is #include int x; void main() { if (x) printf("hi"); else printf("how are u"); }

A. hi
B. how are you
C. compile time error
D. none of the mentioned
Answer» C. compile time error
9.

c = (n) ? a : b; can be rewritten asexp1 ? exp2 : exp3;

A. if(n){c = a;}else{c = b;}
B. if(!n){c = a;}else{c = b;}
C. if(n){c = b;}else{c = a;}
D. None of the above
Answer» B. if(!n){c = a;}else{c = b;}
10.

do-while loop terminates when conditional expression returns?

A. One
B. Zero
C. Non - zero
D. None of the above
Answer» C. Non - zero
11.

Can we use a switch statement to switch on strings?

A. Yes
B. No
Answer» C.
12.

The way the break is used to take control out of switch and continue to take control of the beginning of the switch?

A. Yes
B. No
Answer» C.
13.

What is the output of this C code? void main() { int k; for (k = -3; k < -5; k++) printf("Hello"); }

A. Hello
B. Infinite hello
C. Run time error
D. Nothing
Answer» E.
14.

Which of the following cannot be used as LHS of the expression in for (exp1;exp2; exp3) ?

A. Variable
B. Function
C. typedef
D. macros
Answer» E.
15.

The correct syntax for running two variable for loop simultaneously is.

A. for (i = 0; i < n; i++) for (j = 0; j < n; j += 5)
B. for (i = 0, j = 0;i < n, j < n; i++, j += 5)
C. for (i = 0; i < n;i++){} for (j = 0; j < n;j += 5){}
D. None of the mentioned
Answer» C. for (i = 0; i < n;i++){} for (j = 0; j < n;j += 5){}
16.

The following code for(;;) represents an infinite loop. It can be terminated by.

A. break
B. exit(0)
C. abort()
D. All of the mentioned
Answer» B. exit(0)
17.

Which for loop has range of similar indexes of 'i' used in for (i = 0;i < n>

A. for (i = n; i>0; i )
B. for (i = n; i>=0; i )
C. for (i = n-1; i>0; i )
D. for (i = n-1; i>-1; i )
Answer» E.
18.

What is the output of this C code? int main() { printf("before continue "); continue; printf("after continue n"); }

A. Before continue after continue
B. Before continue
C. after continue
D. Compile time error
Answer» E.
19.

What is the output of this C code? void main() { int i = 0; int j = 0; for (i = 0;i < 5 xss=removed> 1) continue; printf("Hi n"); } } }

A. Hi is printed 9 times
B. Hi is printed 8 times
C. Hi is printed 7 times
D. Hi is printed 6 times
Answer» C. Hi is printed 7 times
20.

What is the output of this C code? void main() { int i = 0, j = 0; for (i = 0;i < 5 xss=removed> 1) break; } printf("Hi n"); } }

A. Hi is printed 5 times
B. Hi is printed 9 times
C. Hi is printed 7 times
D. Hi is printed 4 times
Answer» B. Hi is printed 9 times
21.

#include int main() { int i; for (i = 1; i != 10; i += 2) printf(" GeeksQuiz "); return 0; }

A. GeeksQuiz GeeksQuiz GeeksQuiz GeeksQuiz GeeksQuiz
B. GeeksQuiz GeeksQuiz GeeksQuiz .... infinite times
C. GeeksQuiz GeeksQuiz GeeksQuiz GeeksQuiz
D. GeeksQuiz GeeksQuiz GeeksQuiz GeeksQuiz GeeksQuiz GeeksQuiz
Answer» C. GeeksQuiz GeeksQuiz GeeksQuiz GeeksQuiz
22.

Which keyword is used to come out of a loop only for that iteration?

A. break
B. continue
C. return
D. None of the mentioned
Answer» C. return
23.

Point out the error, if any in the program. #include int main() { int a = 10; switch(a) { } printf("This is c program."); return 0; }

A. Error: No case statement specified
B. Error: No default specified
C. No Error
D. Error: infinite loop occurs
Answer» D. Error: infinite loop occurs
24.

What will be the output of the program? #include int main() { int x, y, z; x=y=z=1; z = ++x || ++y && ++z; printf("x=%d, y=%d, z=%d n", x, y, z); return 0; }

A. x=2, y=1, z=1
B. x=2, y=2, z=1
C. x=2, y=2, z=2
D. x=1, y=2, z=1
Answer» B. x=2, y=2, z=1
25.

Point out the error, if any in the for loop. #include int main() { int i=1; for(;;) { printf("%d n", i++); if(i>10) break; } return 0; }

A. There should be a condition in the for loop
B. The two semicolons should be dropped
C. The for loop should be replaced with while loop.
D. No error
Answer» E.
26.

What will be the output of the program? #include int main() { int x = 10, y = 20; if(!(!x) && x) printf("x = %d n", x); else printf("y = %d n", y); return 0; }

A. y =20
B. x = 0
C. x = 10
D. x = 1
Answer» D. x = 1
27.

What will be the output of the program? #include int main() { int i=3; switch(i) { case 1: printf("Hello n"); case 2: printf("Hi n"); case 3: continue; default: printf("Bye n"); } return 0; }

A. Error: Misplaced continue
B. Bye
C. No output
D. Hello Hi
Answer» B. Bye
28.

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

A. a <= b
B. b > c
C. b >= c and a <= b
D. a > b and b <= c
Answer» E.
29.

Which of the following statements are correct about an if-else statements in a C-program? 1. Every if-else statement can be replaced by an equivalent statements using ?: operators 2. Nested if-else statements are allowed. 3. Multiple statements in an if block are allowed. 4. Multiple statements in an else block are allowed.

A. 1 and 2
B. 2 and 3
C. 1, 2 and 4
D. 2, 3, 4
Answer» E.
30.

What will be the output of the program? #include int main() { int a = 300, b, c; if(a >= 400) b = 300; c = 200; printf("%d, %d, %d n", a, b, c); return 0; }

A. 300, 300, 200
B. Garbage, 300, 200
C. 300, Garbage, 200
D. 300, 300, Garbage
Answer» D. 300, 300, Garbage
31.

#include int main() { unsigned int i = 65000; while (i++ != 0); printf("%d", i); return 0; }

A. Infinite Loop
B. 1
C. Run Time Error
Answer» D.
32.

What will be the output of the program? #include int main() { unsigned int i = 65536; /* Assume 2 byte integer*/ while(i != 0) printf("%d",++i); printf(" n"); return 0; }

A. Infinite loop
B. 0 1 2 ... 65535
C. 0 1 2 ... 32767 - 32766 -32765 -1 0
D. No output
Answer» E.
33.

Which of the following is correct with respect to Jump Statements in C?

A. goto
B. continue
C. break
D. All of the above.
Answer» E.
34.

A typical switch body looks as follows: switch (controlling_expression) { case label1: /*label1 statements*/ break; case label2: /*label1 statements*/ break; default: /*Default statements*/ }

A. switch body may not have any case label at all and it would still compile.
B. switch body may not have the default label and it would still compile.
C. switch body may contain more than one case labels where the label value of these case is same and it would still compile. If switch controlling expression results in this case label value, the case which is placed first would be executed.
D. switch body may not have any break statement and it would still compile.
Answer» D. switch body may not have any break statement and it would still compile.
35.

Which of the following statement is correct for switch controlling expression?

A. Only int can be used in switch control expression
B. Both int and char can be used in switch control expression.
C. All types i.e. int, char and float can be used in switch control expression
D. switch control expression can be empty as well
Answer» C. All types i.e. int, char and float can be used in switch control expression
36.

#include int main() { int i = 3; while (i--) { int i = 100; i--; printf("%d ", i); } return 0; }

A. Infinite Loop
B. 99 99 99
C. 99 98 97
D. 2 2 2
Answer» C. 99 98 97
37.

Which of the following cannot be checked in a switch-case statement?

A. Character
B. Integer
C. Float
D. enum
Answer» D. enum
38.

How many times GeeksQuiz is printed #include int main() { int i = -5; while (i <= 5) { if (i >= 0) break; else { i++; continue; } printf("GeeksQuiz"); } return 0; }

A. 10 times
B. 5 times
C. Infinite times
D. 0 times
Answer» E.
39.

What will be the output of the program? #include int main() { int a=0, b=1, c=3; *((a) ? &b : &a) = a ? b : c; printf("%d, %d, %d n", a, b, c); return 0; }

A. 0, 1, 3
B. 1, 2, 3
C. 3, 1, 3
D. 1, 3, 1
Answer» D. 1, 3, 1
40.

What will be the output of the program? #include int main() { char ch; if(ch = printf("")) printf("It matters n"); else printf("It doesn't matters n"); return 0; }

A. It matters
B. It doesn't matters
C. matters
D. No output
Answer» C. matters
41.

What will be the output of the program? #include int main() { float a = 0.7; if(0.7 > a) printf("Hi n"); else printf("Hello n"); return 0; }

A. Hi
B. Hello
C. Hi Hello
D. None of above
Answer» B. Hello
42.

What will be the output of the program? #include int main() { int x = 3; float y = 3.0; if(x == y) printf("x and y are equal"); else printf("x and y are not equal"); return 0; }

A. x and y are equal
B. x and y are not equal
C. Unpredictable
D. No output
Answer» B. x and y are not equal
43.

What will be the output of the program, if a short int is 2 bytes wide? #include int main() { short int i = 0; for(i<=5 && i>=-1; ++i; i>0) printf("%u,", i); return 0; }

A. 1 ... 65535
B. Expression syntax error
C. No output
D. 0, 1, 2, 3, 4, 5
Answer» B. Expression syntax error
44.

What will be the output of the program? #include int main() { int a = 500, b = 100, c; if(!a >= 400) b = 300; c = 200; printf("b = ? = %d n", b, c); return 0; }

A. b = 300 c = 200
B. b = 100 c = garbage
C. b = 300 c = garbage
D. b = 100 c = 200
Answer» E.
45.

What will be the output of the program? #include int main() { unsigned int i = 65535; /* Assume 2 byte integer*/ while(i++ != 0) printf("%d",++i); printf(" n"); return 0; }

A. Infinite loop
B. 0 1 2 ... 65535
C. 0 1 2 ... 32767 - 32766 -32765 -1 0
D. No output
Answer» B. 0 1 2 ... 65535
46.

What will be the output of the program? #include int main() { int i=0; for(; i<=5; i++); printf("%d", i); return 0; }

A. 0, 1, 2, 3, 4, 5
B. 5
C. 1, 2, 3, 4
D. 6
Answer» E.
47.

What will be the output of the program? #include int main() { char str[]="C-program"; int a = 5; printf(a >10?"Ps n":"%s n", str); return 0; }

A. C-program
B. Ps
C. Error
D. None of above
Answer» B. Ps
48.

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

A. 1245
B. 12345
C. 12245
D. 12354
Answer» C. 12245
49.

How many times the while loop will get executed if a short int is 2 byte wide? #include int main() { int j=1; while(j <= 255) { printf("%c %d n", j, j); j++; } return 0; }

A. Infinite times
B. 255 times
C. 256 times
D. 254 times
Answer» C. 256 times
50.

Consider the following pseudocode: x:=1; i:=1; while (x 500) begin x:=2x ; i:=i+1; end What is the value of i at the end of the pseudocode?

A. 4
B. 5
C. 6
D. 7
Answer» C. 6