OA. free
Free
Qualcomm Embedded Systems & Hardware Core Computer Science Medium

Question (QUESTION: 26 Mark(s): 1) Which of the statement(s) given below is/are correct?

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

Question (QUESTION: 26 | Mark(s): 1)

Which of the statement(s) given below is/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: A. Both (I) and (II) are correct

Statement I is correct: in a nested if structure, the inner if statement can only execute if the outer if condition is true (it controls entry to the inner block). Statement II is correct: the fundamental rule of if blocks in C is that their statements execute only when the condition evaluates to true. Both statements accurately describe C's conditional execution semantics.

Step-by-step Derivation:
Analyze each statement:

Statement I: Consider nested if:

if (outer_condition) {
    if (inner_condition) {
        // inner code
    }
}

The inner if is only reachable if outer_condition is true. Even if inner_condition is false, the outer condition must be true first. TRUE.

Statement II: By definition, if (condition) { statements } executes the statements block only when condition evaluates to true. If condition is false, the block is skipped. TRUE.

Both statements are correct → Answer: A