MCQs on Control Statements | C Programming

Chapter 4: Control Statements.


Conditional Statements (if, if-else, nested if-else)

  1. Which statement is used to test a condition in C?
  • a) for
  • b) while
  • c) if
  • d) switch
  1. What is the syntax of an if statement in C?
  • a) if (condition) { statements; }
  • b) if condition (statements;)
  • c) if condition { statements; }
  • d) if (condition) statements;
  1. What is the output of the following code?
   int x = 5;
   if (x < 10)
       printf("Hello");
   else
       printf("World");
  • a) Hello
  • b) World
  • c) HelloWorld
  • d) No output
  1. In a nested if statement, which else is executed if multiple if statements exist?
  • a) The first else
  • b) The last else
  • c) The nearest if without an else
  • d) None of the above
  1. What will be the output of the following code?
   int x = 5, y = 8;
   if (x < 10)
       if (y > 10)
           printf("A");
       else
           printf("B");
  • a) A
  • b) B
  • c) No output
  • d) Error

Switch Case Statements

  1. Which keyword is used to end a switch statement in C?
  • a) break
  • b) end
  • c) exit
  • d) return
  1. What will happen if the break statement is omitted in a switch case?
  • a) Only that case executes
  • b) Compiler error
  • c) All subsequent cases execute
  • d) The switch ends
  1. Which of the following types cannot be used in a switch expression?
  • a) int
  • b) char
  • c) float
  • d) enum
  1. What is the purpose of the default case in a switch statement?
  • a) To handle all cases
  • b) To execute if no other case matches
  • c) To end the switch
  • d) Optional for all switches
  1. What is the output of the following code?c int x = 2; switch (x) { case 1: printf("One"); case 2: printf("Two"); case 3: printf("Three"); default: printf("Default"); }
    • a) Two
    • b) TwoThreeDefault
    • c) Three
    • d) Default

Loops (for, while, do-while)

  1. Which loop executes at least once, regardless of the condition?
    • a) for
    • b) while
    • c) do-while
    • d) if
  2. What is the output of the following code?int i = 0; while (i < 3) { printf("%d", i); i++; }
    • a) 012
    • b) 123
    • c) 0123
    • d) Error
  3. Which keyword is used to skip an iteration in a loop?
    • a) skip
    • b) continue
    • c) break
    • d) return
  4. How many times will the following code print “Hello”?for (int i = 0; i < 3; i++) { printf("Hello"); }
    • a) 1
    • b) 2
    • c) 3
    • d) Infinite
  5. Which loop is most suitable if the number of iterations is known?
    • a) while
    • b) for
    • c) do-while
    • d) if

Break and Continue

  1. What does the break statement do?
    • a) Stops the loop immediately
    • b) Skips to the next iteration
    • c) Ends the program
    • d) Nothing
  2. What is the output of the following code?for (int i = 0; i < 5; i++) { if (i == 2) break; printf("%d", i); }
    • a) 01234
    • b) 01
    • c) 012
    • d) Error
  3. What does the continue statement do?
    • a) Ends the loop
    • b) Skips the current iteration and continues with the next one
    • c) Exits the program
    • d) None of the above
  4. What is the output of the following code?for (int i = 0; i < 3; i++) { if (i == 1) continue; printf("%d", i); }
    • a) 01
    • b) 02
    • c) 012
    • d) 1
  5. Which statement cannot be used outside loops?
    • a) break
    • b) continue
    • c) return
    • d) printf

Goto and Labels

  1. Which statement allows jumping to a label in C?
    • a) goto
    • b) jump
    • c) continue
    • d) exit
  2. What is a major drawback of using goto statements?
    • a) Code readability decreases
    • b) Execution speed decreases
    • c) Increases complexity
    • d) Both a and c
  3. What is the output of the following code?int x = 0; label: printf("%d", x); x++; if (x < 3) goto label;
    • a) 012
    • b) 123
    • c) 01
    • d) 0
  4. Which keyword is used to mark a label?
    • a) :
    • b) ;
    • c) ->
    • d) .
  5. When should goto be used in C programming?
    • a) To improve efficiency
    • b) To avoid deep nesting of code
    • c) To jump to another function
    • d) None of the above

  1. Which statement correctly represents the syntax of an if-else block?
    • a) if (condition) { statement1; } else { statement2; }
    • b) if (condition) statement1; else statement2;
    • c) if condition statement1; else statement2;
    • d) if (condition) statement1; else { statement2; }
  2. What is the primary purpose of the if statement in C?
    • a) To perform repetitive tasks
    • b) To check a condition and execute a block of code if it’s true
    • c) To allow multiple conditions
    • d) To end the program
  3. In C, what will the else if ladder help achieve?
    • a) Test multiple conditions in sequence
    • b) Create a loop
    • c) Ignore conditional statements
    • d) Execute code only once
  4. What is printed by the following code?int x = 10; if (x == 10) printf("A"); else if (x > 5) printf("B"); else printf("C");
    • a) A
    • b) B
    • c) C
    • d) No output
  5. What will happen if there is no else statement in an if-else construct?
    • a) Code will not compile
    • b) The else statement is optional
    • c) Syntax error
    • d) Compiler warning

Switch Case Statements (continued)

  1. What will be the output of the following code?int x = 3; switch (x) { case 1: printf("One"); break; case 2: printf("Two"); break; case 3: printf("Three"); break; default: printf("Default"); }
    • a) Default
    • b) One
    • c) Three
    • d) Error
  2. Which case in the switch statement will execute if no match is found?
    • a) The first case
    • b) None
    • c) The last case
    • d) The default case
  3. What will be the output of the following code if x = 4?switch (x) { case 3: printf("Three"); break; case 4: printf("Four"); break; default: printf("Default"); }
    • a) Four
    • b) Default
    • c) Three
    • d) Error
  4. Can float be used as an expression in switch statement?
    • a) Yes
    • b) No
    • c) Only with default
    • d) None of the above
  5. In a switch case, which statement is required to prevent fall-through behavior?
    • a) continue
    • b) break
    • c) exit
    • d) None

Loops (continued)

  1. Which loop is known as the entry-controlled loop?
    • a) for
    • b) while
    • c) do-while
    • d) goto
  2. What is the output of the following code?int i = 1; do { printf("%d", i); i++; } while(i < 4);
    • a) 1
    • b) 12
    • c) 123
    • d) Error
  3. Which loop is known as an exit-controlled loop?
    • a) for
    • b) while
    • c) do-while
    • d) None of the above
  4. Which loop is best for situations when the condition must be checked before entering the loop?
    • a) for
    • b) while
    • c) do-while
    • d) goto
  5. How many times will the following code print “Hi”?
    c for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { printf("Hi"); } }
    • a) 2
    • b) 4
    • c) 6
    • d) 8

Break and Continue (continued)

  1. What is the output of the following code?int i = 0; while (i < 5) { i++; if (i == 3) continue; printf("%d", i); }
    • a) 12345
    • b) 1245
    • c) 12
    • d) Error
  2. In which scenarios is the break statement commonly used?
    • a) Loops
    • b) switch statements
    • c) if statements
    • d) Both a and b
  3. Which keyword forces the loop to terminate the current iteration and continue with the next one?
    • a) break
    • b) continue
    • c) exit
    • d) jump
  4. Which will execute only once for each pass of the loop?
    • a) break
    • b) continue
    • c) default
    • d) None
  5. Which loop structure will repeat until i becomes 5?
    c int i = 0; while (i < 5) { i++; }
    • a) for loop
    • b) while loop
    • c) do-while loop
    • d) None

Goto and Labels (continued)

  1. Which statement is a direct jump to another point in the code?
    • a) break
    • b) continue
    • c) goto
    • d) exit
  2. What is printed by the following code?int x = 0; label1: printf("%d", x); x++; if (x < 3) goto label1;
    • a) 123
    • b) 012
    • c) 01
    • d) 0
  3. How does the use of goto generally affect program readability?
    • a) Improves readability
    • b) Makes the program complex and hard to read
    • c) Makes debugging easier
    • d) None of the above
  4. When can goto be useful?
    • a) In structured programming
    • b) To avoid deeply nested conditions
    • c) In modern coding practices
    • d) Both a and c
  5. What is the recommended approach to using goto?
    • a) Use it frequently for efficiency
    • b) Avoid it whenever possible
    • c) Use only for specific situations
    • d) Never use it

Answer Key Table for Chapter 4: Control Statements

QAnswerQAnswerQAnswerQAnswerQAnswer
1c11c21a31c41b
2a12a22d32d42d
3a13b23a33a43b
4c14c24a34b44a
5b15b25b35b45b
6a16a26a36b46c
7c17b27b37c47b
8c18b28a38c48b
9b19b29a39b49b
10b20b30b40b50c

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top