OA. free
Free
Qualcomm Embedded Systems & Hardware Embedded Systems & Hardware Medium

QUESTION 49 Which of the statement(s) given below is/are are correct?

Qualcomm technical mcq question, verified with a worked answer. Free to practise - no sign-up.

QUESTION 49

Which of the statement(s) given below is/are are correct?

I) The inner if statement will be executed if the condition of the outer if statement evaluates to true

II) The statements in the if block execute only if the specified condition evaluates to true

Choose one option.
Show answer & explanation
Answer: D. Both (i) and (ii) are correct

Statement I is correct: in nested if statements, the inner if is only evaluated after the outer if condition is true—the outer condition is a prerequisite. Statement II is correct: this is the fundamental definition of an if block—code inside executes conditionally based on whether the specified condition is true. Both statements accurately describe core control flow behavior.

Step-by-step Derivation:
Evaluation of each statement:

Statement I: 'The inner if statement will be executed if the condition of the outer if statement evaluates to true'

  • In nested if structures, the outer if acts as a guard. If outer_condition is false, the inner if is never reached.
  • If outer_condition is true, execution proceeds to the inner if, where inner_condition is then evaluated.
  • Therefore, Statement I is TRUE: the inner if will execute (or at least be evaluated) only if outer is true.

Statement II: 'The statements in the if block execute only if the specified condition evaluates to true'

  • This is the core definition of conditional execution in programming.
  • An if block's code runs if and only if the condition is true.
  • If condition is false, the if block is skipped.
  • Therefore, Statement II is TRUE: it correctly describes if-statement semantics.

Conclusion: Both I and II are correct → Answer is D.