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.

51.

In C++, which system - provided function is called when no handler is provided to deal with an exception?

A. terminate ( )
B. unexpected ( )
C. abort ( )
D. kill ( )
Answer» B. unexpected ( )
52.

In _______, the bodies of the two loops are merged together to form a single loop provided that they do not make any references to each other.

A. Loop unrolling
B. Strength reduction
C. Loop concatenation
D. Loop jamming
Answer» E.
53.

How many lines of output does the following C code produce? #include float i=2.0; float j=1.0; float sum = 0.0; main() { while (i/j > 0.001) { j+=j; sum=sum+(i/j); printf("%fn", sum); } }

A. 8
B. 9
C. 10
D. 11
Answer» E.
54.

Consider the following program fragment i=6720; j=4; while (i%j)==0 { i=i/j; j=j+1; } On termination j will have the value

A. 4
B. 8
C. 9
D. 6720
Answer» D. 6720
55.

Predict the output of the below program: #include int main() { int i = 3; switch(i) { printf("Outside "); case 1: printf("Geeks"); break; case 2: printf("Quiz"); break; defau1t: printf("GeeksQuiz"); } return 0; }

A. Outside GeeksQuiz
B. GeeksQuiz
C. Nothing gets printed
Answer» D.
56.

What will be the output of the following C program segment? char inchar = 'A'; switch (inchar) { case 'A' : printf ("choice A n") ; case 'B' : printf ("choice B ") ; case 'C' : case 'D' : case 'E' : default: printf ("No Choice") ; }

A. No choice
B. Choice A
C. Choice A
D. Choice B No choice
E. Program gives no output as it is erroneous
Answer» D. Choice B No choice
57.

In the context of "break" and "continue" statements in C, pick the best statement.

A. break can be used in for , while and do-while loop body.
B. continue can be used in for , while and do-while loop body
C. break and continue can be used in for , while , do-while loop body and switch body
D. break and continue can be used in for , while and do-while loop body. But only break can be used in switch body
Answer» E.
58.

Which of the following statements are correct about the below program? #include int main() { int i = 10, j = 20; if(i = 5) && if(j = 10) printf("Have a nice day"); return 0; }

A. Output: Have a nice day
B. No output
C. Error: Expression syntax
D. Error: Undeclared identifier if
Answer» D. Error: Undeclared identifier if
59.

Which of the following statements are correct about the below program? #include int main() { int i = 10, j = 15; if(i % 2 = j % 3) printf("IndiaBIX n"); return 0; }

A. Error: Expression syntax
B. Error: Lvalue required
C. Error: Rvalue required
D. The Code runs successfully
Answer» C. Error: Rvalue required
60.

Point out the error, if any in the while loop. #include int main() { void fun(); int i = 1; while(i <= 5) { printf("%d n", i); if(i>2) goto here; } return 0; } void fun() { here: printf("It works"); }

A. No Error: prints "It works"
B. Error: fun() cannot be accessed
C. Error: goto cannot takeover control to other function
D. No error
Answer» D. No error
61.

Point out the error, if any in the program. #include int main() { int a = 10, b; a >=5 ? b=100: b=200; printf("%d n", b); return 0; }

A. 100
B. 200
C. Error: L value required for b
D. Garbage value
Answer» D. Garbage value
62.

Point out the error, if any in the program. #include int main() { int i = 1; switch(i) { case 1: printf("Case1"); break; case 1*2+4: printf("Case2"); break; } return 0; }

A. Error: in case 1*2+4 statement
B. Error: No default specified
C. Error: in switch statement
D. No Error
Answer» E.
63.

Point out the error, if any in the program. #include int main() { int P = 10; switch(P) { case 10: printf("Case 1"); case 20: printf("Case 2"); break; case P: printf("Case 2"); break; } return 0; }

A. Error: No default value is specified
B. Error: Constant expression required at line case P:
C. Error: There is no break statement in each case.
D. No error will be reported.
Answer» C. Error: There is no break statement in each case.
64.

Which of the following errors would be reported by the compiler on compiling the program given below? #include int main() { int a = 5; switch(a) { case 1: printf("First"); case 2: printf("Second"); case 3 + 2: printf("Third"); case 5: printf("Final"); break; } return 0; }

A. There is no break statement in each case.
B. Expression as in case 3 + 2 is not allowed.
C. Duplicate case case 5:
D. No error will be reported
Answer» D. No error will be reported
65.

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

A. There should be a condition in the while loop
B. There should be at least a semicolon in the while
C. The while loop should be replaced with for loop.
D. No error
Answer» B. There should be at least a semicolon in the while
66.

Point out the error, if any in the program. #include int main() { int i = 1; switch(i) { printf("This is c program."); case 1: printf("Case1"); break; case 2: printf("Case2"); break; } return 0; }

A. Error: No default specified
B. Error: Invalid printf statement after switch statement
C. No Error and prints "Case1"
D. None of above
Answer» D. None of above
67.

What is the output? #include int main() { int n; for (n = 9; n!=0; n--) printf("n = %d", n--); return 0; }

A. 9 7 5 3 1
B. 9 8 7 6 5 4 3 2 1
C. Infinite Loop
D. 9 7 5 3
Answer» D. 9 7 5 3
68.

Output? #include int main() { int c = 5, no = 10; do { no /= c; } while(c--); printf ("%dn", no); return 0; }

A. 1
B. Runtime Error
C. Compiler Error
Answer» C. Compiler Error
69.

#include int i; int main() { if (i); else printf(" lse"); return 0; } What is correct about the above program?

A. if block is executed
B. else block is executed
C. It is unpredictable as i is not initialized
D. Error: misplaced else
Answer» C. It is unpredictable as i is not initialized
70.

Predict the output of the below program: #include #define EVEN 0 #define ODD 1 int main() { int i = 3; switch (i & 1) { case EVEN: printf("Even"); break; case ODD: printf("Odd"); break; default: printf("Default"); } return 0; }

A. Even
B. Odd
C. Default
D. Compile-time error
Answer» C. Default
71.

#include int main() { int i; if (printf("0")) i = 3; else i = 5; printf("%d", i); return 0; }

A. 3
B. 5
C. 03
D. 05
Answer» D. 05
72.

#include int main() { int i = 3; switch (i) { case 0+1: printf("Geeks"); break; case 1+2: printf("Quiz"); break; default: printf("GeeksQuiz"); } return 0; }

A. Geeks
B. Quiz
C. GeeksQuiz
D. Compile-time error
Answer» C. GeeksQuiz
73.

What is the output of the below program? #include int main() { int i = 0; switch (i) { case '0': printf("Geeks"); break; case '1': printf("Quiz"); break; default: printf("GeeksQuiz"); } return 0; }

A. Geeks
B. Quiz
C. GeeksQuiz
D. Compile-time error
Answer» D. Compile-time error
74.

What is the output of this C code? int main() { int *p = NULL; for (foo(); p; p = 0) printf("In for loop n"); printf("After loop n"); }

A. In for loop after loop
B. Compile time error
C. Infinite loop
D. Depends on the value of NULL
Answer» C. Infinite loop
75.

What is the output of this C code? int main() { int i = 0; for (foo(); i == 1; i = 2) printf("In for loop n"); printf("After loop n"); } int foo() { return 1; }

A. After loop
B. In for loop after loop
C. Compile time error
D. Infinite loop
Answer» B. In for loop after loop
76.

What is the output of this C code? void main() { int i = 0; if (i == 0) { printf("Hello"); continue; } }

A. Hello is printed infinite times
B. Hello
C. varies
D. Compile time error
Answer» E.
77.

The modulus operator cannot be used with a long double.

A. True
B. False
Answer» B. False
78.

If scanf() is used to store a value in a char variable then along with the value a carriage return( r) also gets stored it.

A. True
B. False
Answer» C.
79.

A short integer is at least 16 bits wide and a long integer is at least 32 bits wide.

A. True
B. False
Answer» B. False
80.

Which of the following sentences are correct about a switch loop in a C program? 1. switch is useful when we wish to check the value of variable against a particular set of values. 2. switch is useful when we wish to check whether a value falls in different ranges. 3. Compiler implements a jump table for cases used in switch. 4. It is not necessary to use a break in every switch statement.

A. 1,2
B. 1,3,4
C. 2,4
D. 2
Answer» C. 2,4
81.

Which of the following statements are correct about the below program? #include int main() { int n = 0, y = 1; y == 1 ? n=0 : n=1; if(n) printf("Yes n"); else printf("No n"); return 0; }

A. Error: Declaration terminated incorrectly
B. Error: Syntax error
C. Error: Lvalue required
D. None of above
Answer» D. None of above
82.

Which of the following sentences are correct about a for loop in a C program? 1. for loop works faster than a while loop. 2. All things that can be done using a for loop can also be done using a while loop 3. for(;;); implements an infinite loop. 4. for loop can be used if we want statements in a loop get executed at least once.

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

A labeled statement consist of an identifier followed by

A. ;
B. :
C. ,
D. =
Answer» C. ,
84.

Which loop is guaranteed to execute at least one time.

A. for
B. while
C. do while
D. None of the above
Answer» D. None of the above
85.

Switch statement accepts.

A. int
B. char
C. long
D. All of the above
Answer» E.
86.

Which of the following is an invalid if-else statement?

A. if (if (a == 1)){}
B. if (a){}
C. if ((char) a){}
D. if (func1 (a)){}
Answer» B. if (a){}
87.

goto can be used to jump from main to within a function?

A. TRUE
B. FALSE
C. May Be
D. Can't Say
Answer» C. May Be
88.

Which keyword can be used for coming out of recursion?

A. return
B. break
C. exit
D. both A and B
Answer» B. break
89.

The continue statment cannot be used with

A. for
B. while
C. do while
D. switch
Answer» E.
90.

In the following loop construct, which one is executed only once always. for(exp1; exp2; exp3)

A. exp1
B. exp3
C. exp1 and exp3
D. exp1, exp2 and exp3
Answer» B. exp3
91.

We want to test whether a value lies in the range 2 to 4 or 5 to 7. Can we do this using a switch?

A. Yes
B. No
Answer» B. No
92.

By default, the data type of a constant without a decimal point is int, whereas the one with a decimal point is a double.

A. Yes
B. No
Answer» B. No
93.

Which of the following statements are correct about the below program? #include int main() { int i = 0; i++; if(i <= 5) { printf("IndiaBIX n"); exit(0); main(); } return 0; }

A. The program prints 'IndiaBIX' 5 times
B. The program prints 'IndiaBIX' one time
C. The call to main() after exit() doesn't materialize.
D. The compiler reports an error since main() cannot call itself.
Answer» C. The call to main() after exit() doesn't materialize.
94.

The keyword break cannot be simply used within:

A. do-while
B. if-else
C. for
D. while
Answer» C. for