

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.
1. |
What will be the output of the program, if a is 2 bytes wide? |
A. | 1 ... 65535 |
B. | Expression syntax error |
C. | No output |
D. | 0, 1, 2, 3, 4, 5 |
Answer» B. Expression syntax error | |
2. |
Which of the following statements are correct about the below C-program? |
A. | 1 |
B. | 2, 3 |
C. | 3, 4 |
D. | 4 |
Answer» C. 3, 4 | |
3. |
Which of the following sentences are correct about a loop in a C program? |
A. | 1 |
B. | 1, 2 |
C. | 2, 3 |
D. | 2, 3, 4 |
Answer» E. | |
4. |
Which of the following statements are correct about an statements in a C-program? |
A. | 1 and 2 |
B. | 2 and 3 |
C. | 1, 2 and 4 |
D. | 2, 3, 4 |
Answer» E. | |
5. |
A is at least 16 bits wide and a is at least 32 bits wide. |
A. | True |
B. | False |
Answer» B. False | |
6. |
If is used to store a value in a variable then along with the value a carriage return(\r) also gets stored it. |
A. | True |
B. | False |
Answer» C. | |
7. |
The modulus operator cannot be used with a . |
A. | True |
B. | False |
Answer» B. False | |
8. |
The way the is used to take control out of and to take control of the beginning of the ? |
A. | Yes |
B. | No |
Answer» C. | |
9. |
Can we use a statement to switch on strings? |
A. | Yes |
B. | No |
Answer» C. | |
10. |
We want to test whether a value lies in the range 2 to 4 or 5 to 7. Can we do this using a ? |
A. | Yes |
B. | No |
Answer» B. No | |
11. |
By default, the data type of a constant without a decimal point is , whereas the one with a decimal point is a . |
A. | Yes |
B. | No |
Answer» B. No | |
12. |
How many times the loop will get executed if a is 2 byte wide? |
A. | Infinite times |
B. | 255 times |
C. | 256 times |
D. | 254 times |
Answer» C. 256 times | |
13. |
Which of the following cannot be checked in a statement? |
A. | Character |
B. | Integer |
C. | Float |
D. | enum |
Answer» D. enum | |
14. |
Which of the following statements are correct? The switch statement is a control statement that handles multiple selections and enumerations by passing control to one of the case statements within its body. The goto statement passes control to the next iteration of the enclosing iteration statement in which it appears. Branching is performed using jump statements which cause an immediate transfer of the program control. A common use of continue is to transfer control to a specific switch-case label or the default label in a switch statement. The do statement executes a statement or a block of statements enclosed in {} repeatedly until a specified expression evaluates to false. |
A. | 1, 2, 4 |
B. | 1, 3, 5 |
C. | 2, 3, 4 |
D. | 3, 4, 5 |
E. | None of these |
Answer» C. 2, 3, 4 | |
15. |
Which of the following statements are correct? A switch statement can act on numerical as well as Boolean types. A switch statement can act on characters, strings and enumerations types. We cannot declare variables within a case statement if it is not enclosed by { }. 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. All of the expressions of the for statement are not optional. |
A. | 1, 2 |
B. | 2, 3 |
C. | 3, 5 |
D. | 4, 5 |
E. | None of these |
Answer» B. 2, 3 | |
16. |
Which of the following statements are correct about the C#.NET code snippet given below? if (age > 18 || no < 11) a = 25;The condition no < 11 will get evaluated only if age > 18 evaluates to False. The condition no < 11 will get evaluated if age > 18 evaluates to True. The statement a = 25 will get evaluated if any one one of the two conditions is True. || is known as a short circuiting logical operator. The statement a = 25 will get evaluated only if both the conditions are True. |
A. | 1, 4, 5 |
B. | 2, 4 |
C. | 1, 3, 4 |
D. | 2, 3, 5 |
E. | None of these |
Answer» D. 2, 3, 5 | |
17. |
Which of the following can be used to terminate a while loop and transfer control outside the loop? exit while continue exit statement break goto |
A. | 1, 3 |
B. | 2, 4 |
C. | 3, 5 |
D. | 4, 5 |
E. | None of these |
Answer» E. None of these | |
18. |
Which of the following code snippets are the correct way to determine whether a is Odd or Even? int a; String res; if (a % 2 == 0) res = "Even"; else res = "Odd"; int a; String res; if (a Mod 2 == 0) res = "Even"; else res = "Odd"; int a; Console.WriteLine(a Mod 2 == 0 ? "Even": "Odd"); int a; String res; a % 2 == 0 ? res = "Even" : res = "Odd"; Console.WriteLine(res); |
A. | 1, 3 |
B. | 1 Only |
C. | 2, 3 |
D. | 4 Only |
E. | None of these |
Answer» C. 2, 3 | |
19. |
Which of the following is another way to rewrite the code snippet given below?int a = 1, b = 2, c = 0; if (a < b) c = a; |
A. | int a = 1, b = 2, c = 0; c = a < b ? a : 0; |
B. | int a = 1, b = 2, c = 0; a < b ? c = a : c = 0; |
C. | int a = 1, b = 2, c = 0; a < b ? c = a : c = 0 ? 0 : 0; |
D. | int a = 1, b = 2, c = 0; a < b ? return (c): return (0); |
E. | int a = 1, b = 2,c = 0; c = a < b : a ? 0; |
Answer» B. int a = 1, b = 2, c = 0; a < b ? c = a : c = 0; | |
20. |
Which of the following statements are correct about the C#.NET code snippet given below? if (age > 18 && no < 11) a = 25;The condition no < 11 will be evaluated only if age > 18 evaluates to True. The statement a = 25 will get executed if any one condition is True. The condition no < 11 will be evaluated only if age > 18 evaluates to False. The statement a = 25 will get executed if both the conditions are True. && is known as a short circuiting logical operator. |
A. | 1, 3 |
B. | 2, 5 |
C. | 1, 4, 5 |
D. | 3, 4, 5 |
E. | None of these |
Answer» D. 3, 4, 5 | |
21. |
How many times the while loop will get executed if a short int is 2 byte wide?_x000D_
#include
|
A. | Infinite times |
B. | 255 times |
C. | 256 times |
D. | 254 times |
Answer» C. 256 times | |
22. |
What will be the output of the program?_x000D_
#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 | |
23. |
What will be the output of the program?_x000D_
#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. | |
24. |
What will be the output of the program?_x000D_
#include
|
A. | 0, 1, 3 |
B. | 1, 2, 3 |
C. | 3, 1, 3 |
D. | 1, 3, 1 |
Answer» D. 1, 3, 1 | |
25. |
What will be the output of the program?_x000D_
#include
|
A. | Error: Misplaced continue |
B. | Bye |
C. | No output |
D. | Hello Hi |
Answer» B. Bye | |
26. |
What will be the output of the program?_x000D_
#include
|
A. | Hi |
B. | Hello |
C. | Hi Hello |
D. | None of above |
Answer» B. Hello | |
27. |
What will be the output of the program?_x000D_
#include
|
A. | 300, 300, 200 |
B. | Garbage, 300, 200 |
C. | 300, Garbage, 200 |
D. | 300, 300, Garbage |
Answer» D. 300, 300, Garbage | |
28. |
Point out the error, if any in the program._x000D_
#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 | |
29. |
What will be the output of the program?_x000D_
#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 | |
30. |
Which of the following statements are correct about the below C-program?
#include
|
A. | 1 |
B. | 2, 3 |
C. | 3, 4 |
D. | 4 |
Answer» C. 3, 4 | |
31. |
Point out the error, if any in the program._x000D_
#include
|
A. | Error: in case 1*2+4 statement |
B. | Error: No default specified |
C. | Error: in switch statement |
D. | No Error |
Answer» E. | |
32. |
Point out the error, if any in the program._x000D_
#include
|
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. | |
33. |
Which of the following errors would be reported by the compiler on compiling the program given below?_x000D_
#include
|
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. | |
34. |
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 | |
35. |
What will be the output of the program, if a short int is 2 bytes wide?_x000D_
#include
|
A. | 1 ... 65535 |
B. | Expression syntax error |
C. | No output |
D. | 0, 1, 2, 3, 4, 5 |
Answer» B. Expression syntax error | |
36. |
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. | |
37. |
Point out the error, if any in the while loop._x000D_
#include
|
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 | |
38. |
Select the output for the following set of codes: |
A. | -127 to +127 |
B. | 0 to 127 |
C. | 1 |
D. | Infinite loop condition |
Answer» D. Infinite loop condition | |
39. |
For the incomplete program below, which of the code fragment will not result in an infinite loop: |
A. | do { j = j + (i % 10); }while ((i = i / 10)!= 0); |
B. | do { j = j + (i % 10); }while ((i / 10)!= 0); |
C. | do { j = j + (i % 10); }while ((i % 10)!= 0); |
D. | do { j = j + (i % 10); }while ((i/10 == 0)!= 0); |
Answer» B. do { j = j + (i % 10); }while ((i / 10)!= 0); | |
40. |
Correct syntax for while statement is: |
A. | a |
B. | b |
C. | c |
D. | d |
Answer» D. d | |
41. |
Predict the output for the following set of code : |
A. | B B zero A A A |
B. | B zero A A A |
C. | B B B zero A A A |
D. | A A A zero B B B |
Answer» D. A A A zero B B B | |
42. |
Select the output for the set of code: |
A. | Hi Hello |
B. | Hi |
C. | Hello |
D. | Compile time error |
Answer» E. | |
43. |
Correct syntax for do while loop is : |
A. | a |
B. | b |
C. | c |
D. | d |
Answer» E. | |
44. |
Select the output for the following set of Code. Which of the following conditions are true ? |
A. | a ,b ,c |
B. | b ,c ,d |
C. | a ,d ,b |
D. | b ,c |
Answer» E. | |
45. |
Select the correct ‘if statement’ to be filled in the given set of code : |
A. | a |
B. | b |
C. | c |
D. | d |
Answer» D. d | |
46. |
Which of the following statements are correct about the C#.NET code snippet given below?if (age > 18 && no < 11) a = 25;1. The condition no < 11 will be evaluated only if age > 18 evaluates to True.2. The statement a = 25 will get executed if any one condition is True.3. The condition no < 11 will be evaluated only if age > 18 evaluates to False.4. The statement a = 25 will get executed if both the conditions are True.5. && is known as a short circuiting logical operator. |
A. | 1, 3 |
B. | 2, 5 |
C. | 1, 4, 5 |
D. | 3, 4, 5 |
Answer» D. 3, 4, 5 | |
47. |
What is the output for the following code ? |
A. | Rahul Dravid |
B. | Sachin Tendulkar |
C. | Ms Dhoni |
D. | Warning : Unreachable Code |
Answer» C. Ms Dhoni | |
48. |
Which of the following statements are correct about the C#.NET code snippet given below?if (age > 18 || no < 11) a = 25;1. The condition no < 11 will get evaluated only if age > 18 evaluates to False.2. The condition no < 11 will get evaluated if age > 18 evaluates to True.3. The statement a = 25 will get evaluated if any one one of the two conditions is True.4. || is known as a short circuiting logical operator.5. The statement a = 25 will get evaluated only if both the conditions are True. |
A. | 1, 4, 5 |
B. | 2, 4 |
C. | 1, 3, 4 |
D. | 2, 3, 5 |
Answer» D. 2, 3, 5 | |
49. |
Which of the following statements are correct?1. The switch statement is a control statement that handles multiple selections and enumerations by passing control to one of the case statements within its body.2. The goto statement passes control to the next iteration of the enclosing iteration statement in which it appears.3. Branching is performed using jump statements which cause an immediate transfer of the program control.4. A common use of continue is to transfer control to a specific switch-case label or the default label in a switch statement.5. The do statement executes a statement or a block of statements enclosed in {} repeatedly until a specified expression evaluates to false. |
A. | 1, 2, 4 |
B. | 1, 3, 5 |
C. | 2, 3, 4 |
D. | 3, 4, 5 |
Answer» C. 2, 3, 4 | |
50. |
Which of the following is another way to rewrite the code snippet given below? |
A. | int a = 1, b = 2, c = 0;c = a < b ? a : 0; |
B. | int a = 1, b = 2, c = 0;a < b ? c = a : c = 0; |
C. | int a = 1, b = 2, c = 0;a < b ? c = a : c = 0 ? 0 : 0; |
D. | int a = 1, b = 2, c = 0;a < b ? return (c): return (0); |
Answer» B. int a = 1, b = 2, c = 0;a < b ? c = a : c = 0; | |