FSc · Computer Science (Grade 12)

Unit 4 MCQs

48 solved multiple choice questions with answers.

Q1. Control structures are used to

  1. AOnly declare variables
  2. BOnly print output
  3. CControl the flow of execution of a program
  4. DOnly include header files
Show answer
Answer: C. Control the flow of execution of a program
Report a mistake

Q2. Decision statements in C++ include

  1. AOnly while loop
  2. Bif, if-else, nested if, switch
  3. COnly for loop
  4. DOnly functions
Show answer
Answer: B. if, if-else, nested if, switch
Report a mistake

Q3. The simplest decision statement is

  1. Aif statement
  2. Bfor loop
  3. Cwhile loop
  4. Dswitch statement
Show answer
Answer: A. if statement
Report a mistake

Q4. if-else statement is used when

  1. AWe have only one path
  2. BWe only loop
  3. CWe have no condition
  4. DWe have two possible paths
Show answer
Answer: D. We have two possible paths
Report a mistake

Q5. Nested if means

  1. AAn if statement inside another if statement
  2. BOnly switch
  3. COnly loops
  4. DTwo separate if statements
Show answer
Answer: A. An if statement inside another if statement
Report a mistake

Q6. switch statement is used for

  1. AOnly looping
  2. BMulti-way decision making
  3. COnly two-way decision
  4. DOnly functions
Show answer
Answer: B. Multi-way decision making
Report a mistake

Q7. The break statement is used to

  1. AContinue to next iteration
  2. BDeclare a variable
  3. CEnd the program only
  4. DExit from a loop or switch
Show answer
Answer: D. Exit from a loop or switch
Report a mistake

Q8. The continue statement is used to

  1. ASkip the current iteration and continue with next
  2. BEnd the program
  3. CRestart the program
  4. DExit the loop completely
Show answer
Answer: A. Skip the current iteration and continue with next
Report a mistake

Q9. Loops are used for

  1. AOnly decision making
  2. BRepeated execution of a block of code
  3. COnly input/output
  4. DOnly variable declaration
Show answer
Answer: B. Repeated execution of a block of code
Report a mistake

Q10. Types of loops in C++ are

  1. AOnly while
  2. BOnly for
  3. COnly switch
  4. Dfor, while, do-while
Show answer
Answer: D. for, while, do-while
Report a mistake

Q11. for loop is a

  1. ANone
  2. BBoth
  3. CExit-controlled loop
  4. DEntry-controlled loop
Show answer
Answer: D. Entry-controlled loop
Report a mistake

Q12. do-while loop is a

  1. AExit-controlled loop
  2. BEntry-controlled loop
  3. CBoth
  4. DNone
Show answer
Answer: A. Exit-controlled loop
Report a mistake

Q13. The syntax of simple if is

  1. Aif condition statements
  2. Bif{condition}
  3. Cif(condition) { statements; }
  4. Dif: condition
Show answer
Answer: C. if(condition) { statements; }
Report a mistake

Q14. In if-else, the else part is executed when

  1. AAlways
  2. BCondition is false
  3. CCondition is true
  4. DNever
Show answer
Answer: B. Condition is false
Report a mistake

Q15. Nested if-else can be used for

  1. AMultiple conditions
  2. BOnly loops
  3. COnly one condition
  4. DNone
Show answer
Answer: A. Multiple conditions
Report a mistake

Q16. The switch expression must evaluate to

  1. AInteger or character type
  2. BFloat only
  3. CBoolean only
  4. DString only
Show answer
Answer: A. Integer or character type
Report a mistake

Q17. case labels in switch must be

  1. AFloats only
  2. BFunctions
  3. CVariables
  4. DConstant expressions
Show answer
Answer: D. Constant expressions
Report a mistake

Q18. default clause in switch is

  1. ACompulsory
  2. BOptional
  3. CNot allowed
  4. DOnly for loops
Show answer
Answer: B. Optional
Report a mistake

Q19. If break is missing in a case

  1. AError occurs always
  2. BProgram ends
  3. CLoop starts
  4. DExecution falls through to next case
Show answer
Answer: D. Execution falls through to next case
Report a mistake

Q20. exit() function is used to

  1. ARestart program
  2. BContinue loop
  3. CTerminate the program
  4. DExit from loop only
Show answer
Answer: C. Terminate the program
Report a mistake

Q21. while loop checks condition

  1. ABefore executing the body
  2. BOnly once
  3. CNever
  4. DAfter executing the body
Show answer
Answer: A. Before executing the body
Report a mistake

Q22. do-while loop checks condition

  1. AAfter executing the body at least once
  2. BBefore executing the body
  3. COnly at end of program
  4. DNever
Show answer
Answer: A. After executing the body at least once
Report a mistake

Q23. for loop has three parts

  1. AOnly condition
  2. BOnly increment
  3. CInitialization, Condition, Increment/Decrement
  4. DOnly initialization
Show answer
Answer: C. Initialization, Condition, Increment/Decrement
Report a mistake

Q24. Infinite loop can be created by

  1. AAll of these
  2. Bfor(;;)
  3. Cdo{ }while(1)
  4. Dwhile(1)
Show answer
Answer: A. All of these
Report a mistake

Q25. Nested loops mean

  1. AOnly one loop
  2. BA loop inside another loop
  3. CTwo separate loops
  4. DNo loops
Show answer
Answer: B. A loop inside another loop
Report a mistake

Q26. The outer loop in nested loops runs

  1. AOnce for each complete execution of inner loop
  2. BContinuously without inner
  3. CNever
  4. DOnly once
Show answer
Answer: A. Once for each complete execution of inner loop
Report a mistake

Q27. break statement can be used in

  1. AOnly loops
  2. BLoops and switch
  3. COnly if
  4. DOnly switch
Show answer
Answer: B. Loops and switch
Report a mistake

Q28. continue statement can be used in

  1. ALoops only
  2. Bswitch only
  3. Cif only
  4. DFunctions only
Show answer
Answer: A. Loops only
Report a mistake

Q29. goto statement is used for

  1. AUnconditional jump
  2. BConditional jump only
  3. CNone
  4. DLooping only
Show answer
Answer: A. Unconditional jump
Report a mistake

Q30. Using goto is generally

  1. AHighly recommended
  2. BCompulsory
  3. CNot recommended (makes code hard to read)
  4. DOnly for beginners
Show answer
Answer: C. Not recommended (makes code hard to read)
Report a mistake

Q31. The condition in if statement must be enclosed in

  1. ABraces { }
  2. BParentheses ( )
  3. CBrackets [ ]
  4. DNone
Show answer
Answer: B. Parentheses ( )
Report a mistake

Q32. Multiple statements under if must be enclosed in

  1. AParentheses
  2. BNone
  3. CCurly braces { }
  4. DSquare brackets
Show answer
Answer: C. Curly braces { }
Report a mistake

Q33. Relational operators used in conditions are

  1. AOnly &&
  2. BOnly =
  3. C>, <, >=, <=, ==, !=
  4. DOnly +
Show answer
Answer: C. >, <, >=, <=, ==, !=
Report a mistake

Q34. Logical operators used in conditions are

  1. A&&, ||, !
  2. BOnly *
  3. COnly ==
  4. DOnly +
Show answer
Answer: A. &&, ||, !
Report a mistake

Q35. The operator && is

  1. ALogical NOT
  2. BLogical AND
  3. CBitwise AND
  4. DLogical OR
Show answer
Answer: B. Logical AND
Report a mistake

Q36. A loop that never ends is called

  1. AInfinite loop
  2. BNested loop
  3. CEmpty loop
  4. DFinite loop
Show answer
Answer: A. Infinite loop
Report a mistake

Q37. Empty loop means

  1. ALoop with no body (null statement)
  2. BNone
  3. CInfinite loop
  4. DNested loop
Show answer
Answer: A. Loop with no body (null statement)
Report a mistake

Q38. The loop variable in for is usually

  1. AUpdated in the increment part
  2. BUpdated only in body
  3. CNever updated
  4. DNone
Show answer
Answer: A. Updated in the increment part
Report a mistake

Q39. while(false) will execute the body

  1. AFive times
  2. BZero times
  3. COne time
  4. DInfinite times
Show answer
Answer: B. Zero times
Report a mistake

Q40. do{ }while(false) will execute the body

  1. AOne time
  2. BTwo times
  3. CZero times
  4. DInfinite times
Show answer
Answer: A. One time
Report a mistake

Q41. for(i=0; i<5; i++) will execute

  1. AInfinite times
  2. B4 times
  3. C5 times
  4. D6 times
Show answer
Answer: C. 5 times
Report a mistake

Q42. The value of i after for(i=0; i<5; i++) finishes is

  1. A4
  2. B0
  3. C6
  4. D5
Show answer
Answer: D. 5
Report a mistake

Q43. switch can replace

  1. AOnly loops
  2. BOnly one if
  3. CMultiple if-else statements
  4. DOnly functions
Show answer
Answer: C. Multiple if-else statements
Report a mistake

Q44. case values in switch must be unique

  1. ATrue
  2. BOptional
  3. COnly for int
  4. DFalse
Show answer
Answer: A. True
Report a mistake

Q45. Floating-point values cannot be used in

  1. Aif condition
  2. Bswitch expression
  3. Cfor condition
  4. Dwhile condition
Show answer
Answer: B. switch expression
Report a mistake

Q46. The purpose of control structures is to

  1. ANone
  2. BOnly print Hello World
  3. COnly declare variables
  4. DMake programs flexible and powerful
Show answer
Answer: D. Make programs flexible and powerful
Report a mistake

Q47. Selection statements are also called

  1. AJumping statements only
  2. BNone
  3. CDecision statements / Conditional statements
  4. DLooping statements
Show answer
Answer: C. Decision statements / Conditional statements
Report a mistake

Q48. Iteration statements are also called

  1. ADecision statements
  2. BJump statements only
  3. CLooping statements
  4. DNone
Show answer
Answer: C. Looping statements
Report a mistake