

MCQOPTIONS
Saved Bookmarks
This section includes 117 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
51. |
Select output for the following set of code: |
A. | 1 2 3 4 5 6 7 8 9 |
B. | 25 |
C. | 1 |
D. | Run time error |
Answer» E. | |
52. |
Which of the code should be added to get the following output? |
A. | for (i = 0;i <= 4; i++){for(j = 4;j <= i; j–)console.WriteLine(“*”);console.WriteLine(“\n”);} |
B. | for (i = 0;i <= 4; i++) |
C. | for (i = 0;i <= 4; i++){for (j = i;j <= 4; j++)console.WriteLine(“*”);console.WriteLine(“\n”);} |
D. | for ( i = 0;i <= 4; i++){for (j = 0;j <= i; j++)console.WriteLine(“*”);console.WriteLine(“\n”);} |
Answer» D. for ( i = 0;i <= 4; i++){for (j = 0;j <= i; j++)console.WriteLine(“*”);console.WriteLine(“\n”);} | |
53. |
Select the output for the following set of code. |
A. | 3 Idiots |
B. | Ghazini |
C. | Race |
D. | Krishh |
Answer» D. Krishh | |
54. |
Select output for the following set of code : |
A. | 1 3 1 |
B. | 2 3 4 |
C. | 5 3 4 |
D. | Compile time error. |
Answer» B. 2 3 4 | |
55. |
Select the output for the following code : |
A. | amish |
B. | ANKIT |
C. | harsh |
D. | Compile time error |
Answer» E. | |
56. |
Select the output for the following set of Code: |
A. | Compile time error |
B. | case A|case a |
C. | case B|case b |
D. | case D|case d |
Answer» E. | |
57. |
Select output for the following code: |
A. | 23 |
B. | 15 |
C. | Compile time error |
D. | 12 |
Answer» D. 12 | |
58. |
Which of the following is not infinite loop? |
A. | for( ;’0′; ) |
B. | for( ;’0′; ) |
C. | for( ;’1′; ) |
D. | for( ;’1′; ) |
Answer» B. for( ;’0′; ) | |
59. |
Which of the following statements are correct?1. A switch statement can act on numerical as well as Boolean types.2. A switch statement can act on characters, strings and enumerations types.3. We cannot declare variables within a case statement if it is not enclosed by { }.4. The foreach statement is used to iterate through the collection to get the desired information and should be used to change the contents of the collection to avoid unpredictable side effects.5. All of the expressions of the for statement are not optional. |
A. | 1, 2 |
B. | 2, 3 |
C. | 3, 5 |
D. | 4, 5 |
Answer» B. 2, 3 | |
60. |
Which statement is correct among the mentioned statements?1. The for loop works faster than a while loop2. for( ; ; )implements an infinite loop |
A. | Only 1 is correct |
B. | Only 2 is correct |
C. | Both 1 and 2 are correct |
D. | Both 1 and 2 are incorrect |
Answer» C. Both 1 and 2 are correct | |
61. |
Which of the following can be used to terminate a while loop and transfer control outside the loop?1. exit while2. continue3. exit statement4. break5. goto |
A. | 1, 3 |
B. | 2, 4 |
C. | 3, 5 |
D. | 4, 5 |
Answer» E. | |
62. |
The keyword 'break' cannot be simply used within _________ |
A. | do-while |
B. | if-else |
C. | for |
D. | while |
Answer» C. for | |
63. |
Which keyword can be used for coming out of recursion? |
A. | break |
B. | return |
C. | exit |
D. | both break and return |
Answer» C. exit | |
64. |
Which datatype can accept switch statement? |
A. | int |
B. | char |
C. | long |
D. | all of the mentioned |
Answer» E. | |
65. |
The C code 'for(;;)' represents an infinite loop. It can be terminated by ___________ |
A. | break |
B. | exit(0) |
C. | abort() |
D. | terminate |
Answer» B. exit(0) | |
66. |
Which for loop has range of similar indexes of 'i' used in for (i = 0;i < n; i++)? |
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. | |
67. |
Which loop is most suitable to first perform the operation and then test the condition? |
A. | for loop |
B. | while loop |
C. | do-while loop |
D. | none of the mentioned |
Answer» D. none of the mentioned | |
68. |
What will be the output of the program?
#include
|
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 | |
69. |
Point out the error, if any in the while loop.
#include
|
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 | |
70. |
What will be the output of the program?
#include
|
A. | 0, 1, 3 |
B. | 1, 2, 3 |
C. | 3, 1, 3 |
D. | 1, 3, 1 |
Answer» D. 1, 3, 1 | |
71. |
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. | |
72. |
What will be the output of the program?
#include
|
A. | This is default This is case 1 |
B. | This is case 3 This is default |
C. | This is case 1 This is case 3 |
D. | This is default |
Answer» B. This is case 3 This is default | |
73. |
What will be the output of the program?
#include
|
A. | Hi |
B. | Hello |
C. | Hi Hello |
D. | None of above |
Answer» B. Hello | |
74. |
What will be the output of the program?
#include
|
A. | 4, 3, 2, 1, 0, -14, 3, 2, 1, 0, -1 |
B. | 5, 4, 3, 2, 1, 05, 4, 3, 2, 1, 0 |
C. | Error |
D. | 5, 4, 3, 2, 1, 05, 4, 3, 2, 1, 05, 4, 3, 2, 1, 0 |
Answer» B. 5, 4, 3, 2, 1, 05, 4, 3, 2, 1, 0 | |
75. |
What will be the output of the program?
#include
|
A. | HelloHi |
B. | HelloBye |
C. | Hi |
D. | Bye |
Answer» D. Bye | |
76. |
What will be the output of the program?
#include
|
A. | 2 13 14 15 16 17 0 |
B. | 2 13 14 15 16 1 |
C. | 2 13 14 15 1 |
D. | 2 23 34 45 5 |
Answer» B. 2 13 14 15 16 1 | |
77. |
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 | |
78. |
What will be the output of the program?
#include
|
A. | Infinite loop |
B. | 0 1 2 ... 65535 |
C. | 0 1 2 ... 32767 - 32766 -32765 -1 0 |
D. | No output |
Answer» E. | |
79. |
What will be the output of the program?
#include
|
A. | It matters |
B. | It doesn't matters |
C. | matters |
D. | No output |
Answer» C. matters | |
80. |
What will be the output of the program?
#include
|
A. | 1 2 3 ... 127 |
B. | 1 2 3 ... 255 |
C. | 1 2 3 ... 127 128 0 1 2 3 ... infinite times |
D. | 1, 2, 3, 4 |
Answer» E. | |
81. |
Which of the following statements are correct about the below program?
#include
|
A. | Error: Declaration terminated incorrectly |
B. | Error: Syntax error |
C. | Error: Lvalue required |
D. | None of above |
Answer» D. None of above | |
82. |
What will be the output of the program?
#include
|
A. | 300, 300, 200 |
B. | Garbage, 300, 200 |
C. | 300, Garbage, 200 |
D. | 300, 300, Garbage |
Answer» D. 300, 300, Garbage | |
83. |
Point out the error, if any in the program.
#include
|
A. | Error: in case 1*2+4 statement |
B. | Error: No default specified |
C. | Error: in switch statement |
D. | No Error |
Answer» E. | |
84. |
What will be the output of the program?
#include
|
A. | Error: Misplaced continue |
B. | Bye |
C. | No output |
D. | Hello Hi |
Answer» B. Bye | |
85. |
Point out the error, if any in the program.
#include
|
A. | 100 |
B. | 200 |
C. | Error: L value required for b |
D. | Garbage value |
Answer» D. Garbage value | |
86. |
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 | |
87. |
What will be the output of the program?
#include
|
A. | 200 |
B. | 30 |
C. | 100 |
D. | 500 |
Answer» C. 100 | |
88. |
What will be the output of the program?
#include
|
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 | |
89. |
What will be the output of the program?
#include
|
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 | |
90. |
Point out the error, if any in the program.
#include
|
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 | |
91. |
What will be the output of the program, if a short int is 2 bytes wide?
#include
|
A. | 1 ... 65535 |
B. | Expression syntax error |
C. | No output |
D. | 0, 1, 2, 3, 4, 5 |
Answer» B. Expression syntax error | |
92. |
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 | |
93. |
Which of the following statements are correct about the below program?
#include
|
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. |
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. | 1 |
B. | |
Answer» C. | |
95. |
Which of the following statements are correct about the below program?
#include
|
A. | Error: Expression syntax |
B. | Error: Lvalue required |
C. | Error: Rvalue required |
D. | The Code runs successfully |
Answer» C. Error: Rvalue required | |
96. |
Can we use a switch statement to switch on strings? |
A. | Yes |
B. | No |
Answer» C. | |
97. |
What will be the output of the program?
#include
|
A. | b = 300 c = 200 |
B. | b = 100 c = garbage |
C. | b = 300 c = garbage |
D. | b = 100 c = 200 |
Answer» E. | |
98. |
Which of the following statements are correct about the program?
#include
|
A. | Error: Statement missing |
B. | Error: Expression syntax |
C. | Error: Lvalue required |
D. | Error: Rvalue required |
Answer» B. Error: Expression syntax | |
99. |
Point out the error, if any in the program.
#include
|
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 | |
100. |
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. | |