Sequence Control in C Programming MCQ Questions and Answers

1. Which statement best describes “sequence control” in C?
A) Execution of statements in arbitrary order
B) Execution of statements strictly from top to bottom unless altered by control constructs
C) Execution only of function calls
D) Execution only of conditional statements
[Answer:] B

2. What will the following code print?
int x = 5;
printf(“%d”, ++x + x++);
A) 11
B) Undefined behavior
C) 12
D) 10
[Answer:] B

3. Which construct is NOT part of C’s sequence control mechanisms?
A) for loop
B) if-else
C) class
D) switch
[Answer:] C

4. In a C program, where does execution always begin?
A) main function
B) first declared function in file
C) any function called by the compiler
D) start label
[Answer:] A

5. Which of the following changes flow of control by jumping to another location unconditionally?
A) break
B) continue
C) goto
D) return
[Answer:] C

6. What does the continue statement do inside a loop?
A) Terminates the loop completely
B) Skips the rest of current iteration and proceeds to next iteration
C) Jumps to the beginning of the program
D) Returns from the function
[Answer:] B

7. Which loop executes its body at least once?
A) for
B) while
C) do-while
D) none of these
[Answer:] C

8. What is the result of if(0) in C?
A) Condition true
B) Syntax error
C) Condition false
D) Undefined
[Answer:] C

9. Which of the following is a valid use of the conditional (ternary) operator?
A) condition ? expression1 : expression2
B) condition ?: expression
C) condition ? expression1, expression2
D) condition ? (expression1; expression2)
[Answer:] A

10. In a switch statement, which data types are allowed for the controlling expression (in standard C)?
A) float and double
B) int, char and enumeration types (and types promotable to int)
C) long double only
D) struct types
[Answer:] B

11. Which statement exits the nearest enclosing loop immediately?
A) return
B) goto
C) continue
D) break
[Answer:] D

12. What is the output of:
int i=0;
if(i==0) printf(“zero”); else printf(“not”);
A) zero
B) not
C) zero not
D) Compiler error
[Answer:] A

13. Which of these is true about nested loops?
A) Inner loop cannot modify outer loop variable
B) Inner loop always executes fewer times than outer loop
C) Outer loop will not execute if inner loop exists
D) Inner loop is completely executed for each single iteration of outer loop
[Answer:] D

14. What does short-circuit evaluation mean in C?
A) All operands are always evaluated
B) Evaluation stops as soon as the result is determined for && and ||
C) & and | operators behave like && and ||
D) It applies only to arithmetic operations
[Answer:] B

15. Which operator has higher precedence: && or ||?
A) both same precedence
B) ||
C) &&
D) precedence depends on compiler
[Answer:] C

16. What happens if there is no break in a switch case?
A) Compile-time error
B) Falling through to the next case
C) Program exits
D) It ignores remaining cases
[Answer:] B

17. Which of these is a correct for loop header?
A) for(int i=0; i<10; i++)
B) for(int i=0; i<10;)
C) for(; ; )
D) All of the above
[Answer:] D

18. Consider:
int a = 5;
if(a = 0) printf(“A”); else printf(“B”);
What prints?
A) A
B) B
C) Compiler error
D) Undefined behavior
[Answer:] B

19. Which keyword transfers control out of a function?
A) break
B) continue
C) return
D) exit
[Answer:] C

20. Which of the following will create an infinite loop?
A) for(;;)
B) while(1)
C) do { } while(1);
D) All of these
[Answer:] D

21. Which of the following is true about goto in C?
A) It can jump to a label in another function
B) It can jump forward or backward within the same function
C) It can transfer execution to arbitrary memory address
D) It is recommended in structured programming as primary control mechanism
[Answer:] B

22. What is the effect of break inside a switch?
A) Exits only the current case block and continues loop
B) Exits the switch and continues with the next statement after it
C) Exits the function
D) Repeats the switch from the start
[Answer:] B

23. What will the following code print?
int x=1;
if(x) printf(“yes”);
A) yes
B) nothing
C) Compiler error
D) 1
[Answer:] A

24. Which statement is true about while loop?
A) Evaluates condition after executing the loop body
B) Uses a loop counter implicitly
C) Evaluates condition before executing the loop body
D) Cannot be used for indefinite loops
[Answer:] C

25. Which of the following is NOT a valid switch label?
A) case 5:
B) default:
C) case ‘A’:
D) case 3.14:
[Answer:] D

26. How many times will this print “Hi”?
for(int i=0;i<5;i++)
printf(“Hi”);
A) 4
B) 5
C) 6
D) Undefined
[Answer:] B

27. What is the output of:
int x=3;
printf(“%d”, x>1? x<5? x:5:0);
A) 3
B) 5
C) 0
D) Compiler error
[Answer:] A

28. Which construct allows multiple entry points into code segment?
A) structured if
B) switch alone
C) goto with labels
D) function prototypes
[Answer:] C

29. Which of the following is allowed as expression in if?
A) float value
B) string literal
C) integer expression convertible to boolean (nonzero true)
D) array
[Answer:] C

30. What happens when return is executed inside main?
A) Program continues after main
B) Program terminates and returns value to calling environment
C) Compiler error
D) Triggers infinite loop
[Answer:] B

31. Which of the following best describes do-while behavior?
A) Test at start, may skip body
B) Test at end, body executes at least once
C) Must have loop counter
D) Replaces for loop always
[Answer:] B

32. In for(init; cond; incr), which executes first?
A) cond
B) incr
C) init
D) body
[Answer:] C

33. Consider if (a && b()) — when is b() NOT called?
A) When a is nonzero
B) When a evaluates to zero (false)
C) b() is always called
D) When compiler optimizes it away
[Answer:] B

34. Which operator can be used in conditional expressions to avoid if-else?
A) comma operator
B) bitwise AND
C) ternary ?: operator
D) sizeof
[Answer:] C

35. In a switch statement, the case labels must be:
A) runtime calculated
B) constant expressions known at compile time
C) variables
D) pointers
[Answer:] B

36. Which statement about break inside nested loops is correct?
A) breaks all loops at once
B) breaks only the innermost loop where it appears
C) breaks outermost loop only
D) causes program to terminate
[Answer:] B

37. What does the default label in switch do?
A) Executed when no other case matches
B) Compulsory for every switch
C) Must be the last case only
D) Replaces break statements
[Answer:] A

38. What will be the output?
int a = 2;
switch(a) {
case 1: printf(“one”); break;
default: printf(“def”);
case 2: printf(“two”);
}
A) one
B) two
C) deftwo
D) Compiler error
[Answer:] C

39. Which describes if-else if-else chain evaluation?
A) All conditions are evaluated always
B) Evaluation stops at first true branch
C) else-if conditions are evaluated in reverse order
D) Compiler randomly picks a branch
[Answer:] B

40. Which is true for while with condition that never becomes false?
A) It becomes a finite loop
B) It becomes infinite loop
C) Compiler will optimize to break it
D) It will throw runtime exception
[Answer:] B

41. Which of the following is valid to write in place of loop body when nothing is needed?
A) ; (empty statement)
B) {} (empty block)
C) both A and B
D) None of these
[Answer:] C

42. What will the expression !5 evaluate to in C?
A) 1
B) 0
C) 5
D) Undefined
[Answer:] B

43. Which header is required for exit() function?
A) <stdio.h>
B) <stdlib.h>
C) <string.h>
D) <math.h>
[Answer:] B

44. What is the effect of continue in a for loop?
A) Discards rest of body and executes increment expression, then condition check
B) Breaks out of the loop entirely
C) Jumps to function return
D) Restarts the entire program
[Answer:] A

45. Which of following combinations is valid to control loops using integer?
A) for(int i=0;i<10;i+=2)
B) while(i–)
C) do { } while(–n);
D) All of the above
[Answer:] D

46. What value does scanf return?
A) Number of input items successfully matched and assigned
B) Always 1
C) Number of characters in input
D) Boolean value only
[Answer:] A

47. What will be output of following?
int x=0;
if(x=1) printf(“A”); else printf(“B”);
A) A
B) B
C) Compiler error
D) Nothing
[Answer:] A

48. Which of the following is true about switch fallthrough?
A) It cannot be used intentionally
B) Using fallthrough without break allows executing subsequent case bodies
C) Compiler always warns and forbids it
D) It duplicates case labels automatically
[Answer:] B

49. Which of the following is a valid reason to use goto?
A) To create spaghetti code intentionally
B) To break out from deeply nested loops in legacy code (rare justified use)
C) To replace all loops for readability
D) It’s always preferable to structured loops
[Answer:] B

50. The ?: ternary operator associates:
A) Left-to-right
B) Right-to-left
C) Depends on compiler
D) Not associative
[Answer:] B

51. Which is true about labels used by goto?
A) Must be at function scope (same function)
B) Can be declared in header and used across files
C) Stored in static memory outside functions
D) Cannot be used more than once in program
[Answer:] A

52. What is the purpose of break in a for loop?
A) Skip next iteration
B) Exit the loop entirely and continue after it
C) Restart the loop with same index
D) Convert to while loop
[Answer:] B

53. What is the output?
int i = 0;
while(i++ < 3) printf(“%d”, i);
A) 123
B) 1123
C) 234
D) 1234
[Answer:] C

54. In for(int i=0;i<5;++i), what is difference between i++ and ++i in header?
A) No difference in this context
B) ++i is illegal in header
C) i++ does not increment
D) ++i doubles the value
[Answer:] A

55. Which of the following is true when condition in if is expression with side effects?
A) Side effects always ignored
B) Side effects happen when expression evaluates (possibly short-circuited)
C) Compiler prevents side-effects in conditions
D) Side effects executed after if block
[Answer:] B

56. Which statement ends program immediately returning a status code?
A) break
B) exit(status)
C) continue
D) goto end
[Answer:] B

57. What is printed by:
for(int i=0;i<3;i++)
if(i==1) break;
printf(“Done”);
A) Done
B) Prints nothing
C) Done printed thrice
D) Compiler error
[Answer:] A

58. The comma operator in C:
A) Evaluates left expression then right, returns right’s value
B) Adds numbers
C) Separates function parameters only
D) Causes compile error outside loops
[Answer:] A

59. Which of these is evaluated first in a && b || c?
A) a then b, then c (short-circuited rules apply)
B) c then b then a
C) b then a then c
D) Compiler decides randomly
[Answer:] A

60. Which behavior is undefined in sequence control?
A) modifying and using same variable without sequence point (in older C rules)
B) using if with integer expression
C) using for with complicated condition
D) using switch with constants
[Answer:] A

61. Which of the following is a sequence point in C (C11 semantics: sequencing rules)?
A) Between evaluation of left and right operands of && operator when right not evaluated
B) After evaluation of full expression and before next statement execution (post-expression sequencing)
C) Between two statements separated by semicolon (end of statement)
D) All of the above (conceptually for sequencing)
[Answer:] D

62. How many times does inner loop run in:
for(int i=0;i<3;i++)
for(int j=0;j<2;j++);
A) 6 (body omitted)
B) 0
C) 2
D) 3
[Answer:] A

63. Which of these is true about the if condition if(a & b)?
A) Uses bitwise AND, not logical AND
B) Uses logical AND operator
C) Always same as if(a && b)
D) Invalid expression in C
[Answer:] A

64. In switch, case labels must be unique within same switch. What happens if duplicate constant used?
A) Last one used
B) Compile-time error
C) Runtime chooses first
D) Undefined behavior
[Answer:] B

65. Which operator is used to group multiple statements where only one statement is syntactically allowed?
A) semicolon
B) comma
C) block { … }
D) parentheses
[Answer:] C

66. Which of the following is true about if without braces?
A) It can control only the next single statement
B) It controls all following statements until semicolon
C) Compiler treats next line as separate block always
D) It controls function body
[Answer:] A

67. What will the following code output?
int n=3;
do {
printf(“%d”, n–);
} while(n>0);
A) 321
B) 3321
C) 3210
D) 123
[Answer:] A

68. What is the result of 0 && (1/0)?
A) Runtime error division by zero
B) 0 (short-circuited no division)
C) Undefined behavior always
D) 1
[Answer:] B

69. Which statement about switch ranges is correct?
A) C switch supports range cases like case 1…3: in standard C
B) Standard C does not support case ranges; each case must be a single constant
C) case ranges are mandatory
D) case ranges are supported for floats only
[Answer:] B

70. Which of these will skip the current iteration in while loop?
A) break
B) continue
C) return
D) goto label
[Answer:] B

71. Which of the following will produce a compile error?
A) case labels with non-integer constant expression
B) while loop with boolean condition
C) for loop without initialization
D) empty statement ; outside loops
[Answer:] A

72. Which statement is true about for loop variable declared inside header, e.g., for(int i=0;…)?
A) i has block scope and not accessible after loop in C99 and later
B) i remains accessible globally
C) i is static variable
D) i is accessible in other functions
[Answer:] A

73. In if (a = b), what common mistake occurs?
A) assignment used instead of comparison ==
B) a equals b permanently becomes constant
C) compiler error prevented assignment in condition
D) Always compiles to false
[Answer:] A

74. Which of the following is true about nested if-else without braces and else placement?
A) else always pairs with nearest unmatched if (dangling else)
B) else pairs with outermost if by default
C) Compiler will prompt to which if it pairs
D) else remains unpaired if multiple ifs exist
[Answer:] A

75. What happens if main has return; without value in a function declared int main()?
A) Compiler error
B) Implicit return 0 in C99 and later (if control reaches end) — but return; in int main is ill-formed; use return 0;
C) Returns garbage
D) Program crash
[Answer:] B

76. Which of these is correct about switch (x) when x is negative?
A) Works fine if case constants include that negative constant
B) Not allowed: x must be positive
C) Compiler will convert negative to unsigned and cause error
D) Switch cannot evaluate negative values
[Answer:] A

77. In C, what is the effect of evaluating a || b() when a is true (nonzero)?
A) b() is evaluated anyway
B) b() is not evaluated due to short-circuit
C) Program undefined
D) b() is evaluated after a delay
[Answer:] B

78. Which of the following statements about break in switch is false?
A) Without break, control falls through
B) break exits only the switch, not outer loops unless inside one
C) break exits function always
D) break may be omitted intentionally to allow fallthrough
[Answer:] C

79. Which is a correct way to loop over array indices 0..n-1?
A) for(int i=0;i<n;i++)
B) while(n–) { /* uses n modified / }
C) for(int i=n;i>0;i–) / careful with index use */
D) All can be correct depending on use, but A is standard clear approach
[Answer:] D

80. How does if statement treat negative integers?
A) Any nonzero integer including negative is considered true
B) Negative integers are considered false
C) Only positive integers true
D) Causes undefined behavior
[Answer:] A

81. Which of the following will always produce a sequence point (C11 sequencing)?
A) End of full expression (e.g., after 😉
B) Operator , within expressions (comma operator) introduces sequencing between left and right
C) Between evaluation of function arguments — function argument evaluations are unsequenced relative to each other (so not guaranteed)
D) Both A and B (C is false)
[Answer:] D

82. What is printed by:
int i = 0;
for(; i<1; i++)
if(i) printf(“A”); else printf(“B”);
A) A
B) B
C) Nothing
D) Compiler error
[Answer:] B

83. Which is true about while(0) used with macro constructs?
A) Common idiom to create block that never executes, used for macro safety with do { } while(0);
B) Causes compile error in macros
C) Deprecated practice always
D) Converts to infinite loop
[Answer:] A

84. Which expression is valid in case?
A) case 1+2:
B) case variable:
C) case func():
D) case a+b: where a and b are non-const variables
[Answer:] A

85. What is the effect of return 0; in main?
A) signals successful termination to the host environment
B) throws exception to OS
C) reloads program
D) causes undefined behavior
[Answer:] A

86. Which of these can be used to implement an endless repeat-until loop in C?
A) for(;;) { … }
B) while(1) { … }
C) do { … } while(1);
D) All of the above
[Answer:] D

87. What is the value of i after this loop?
int i=0;
for(; i<5; ++i);
A) 4
B) 5
C) 0
D) Undefined
[Answer:] B

88. Which of these is a common bug when not using braces with if?
A) Only first statement controlled by if, unexpectedly executing others
B) Syntax error always
C) Compiler converts subsequent statements into else
D) Program runs slower
[Answer:] A

89. In which scenario might goto improve clarity (rarely)?
A) To break out from multiple nested loops to a cleanup label in error handling
B) To replace all switch statements
C) To jump into another function
D) To create infinite loops easier
[Answer:] A

90. Which operator could change evaluation order and thus affect sequence control?
A) comma operator
B) logical && and || due to short-circuiting
C) ternary ?: within complex expressions
D) All of the above
[Answer:] D

91. What will this code print?
int x=1,y=2;
if(x>y) printf(“A”); else if(x==y) printf(“B”); else printf(“C”);
A) A
B) B
C) C
D) Compiler error
[Answer:] C

92. Which of these statements about loop variable declared outside loop is true?
A) It remains accessible after loop ends
B) It disappears immediately after loop iteration
C) It resets to zero automatically
D) Compiler error if accessed later
[Answer:] A

93. Which of the following is NOT a correct way to exit a loop early?
A) break
B) return
C) goto label after loop
D) none of the above
[Answer:] D

94. What is the primary difference between while and do-while?
A) while tests condition before body; do-while after body
B) while cannot be infinite
C) do-while requires semicolon after closing parenthesis; while does not
D) do-while is slower always
[Answer:] A

95. Which of the following is true about switch performance?
A) switch with contiguous integer cases may be optimized to jump table improving performance
B) switch always slower than equivalent if-else chain
C) switch cannot be optimized by compiler
D) switch is only for strings
[Answer:] A

96. Which of these is the correct semantics of if (expr) when expr is a floating point zero 0.0?
A) 0.0 is false (treated as zero)
B) 0.0 is true
C) Compiler error mixing floats and conditions
D) Behavior depends on platform
[Answer:] A

97. Which of the following control constructs can contain declarations in their header (C99 and later)?
A) for (int i=0; … )
B) while (int i=0)
C) if (int x = func()) // note: C doesn’t allow declarations like this in condition the way C++ does
D) switch (int x = 0)
[Answer:] A

98. What happens if a switch expression evaluates to a value for which there is no case and no default?
A) Control falls out of switch without executing any branch
B) Runtime error thrown
C) First case executed by default
D) Program crashes
[Answer:] A

99. Which of the following is true in C about mixing function calls and sequence points?
A) Order of evaluation of function arguments is unspecified and may be interleaved (unsequenced prior to C11 rules) — don’t rely on side effects across arguments
B) Function arguments evaluated left to right always
C) Function arguments evaluated right to left always
D) Compiler guarantees evaluation order as per programmer’s will
[Answer:] A

100. Which is a correct reason to prefer structured loops (for, while) over goto?
A) Structured loops improve readability and maintainability and map natural iteration patterns
B) goto is faster in every case
C) goto cannot be compiled on modern compilers
D) Structured loops are deprecated
[Answer:] A