OA. free
Free
Qualcomm Core Computer Science Core Computer Science Medium

The following C code segment attempts to determine if a number is even or odd.

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

The following C code segment attempts to determine if a number is even or odd. Identify any potential error (if exists) and choose the correct fix from the options.

#include <stdio.h> // Line 1

int main() {
    int num;
    printf("Enter a number: ");
    scanf("%d", &num);
    if (num % 2 = 0) {
        printf("%d is even\n", num);
    } else {
        printf("%d is odd\n", num);
    }
    return 0;
}
Choose one option.
Show answer & explanation
Answer: A. A) Missing semicolon; Fix: Add semicolon at the end of line 1

Rigorous technical derivation based on engineering and aptitude principles.

Step-by-step Derivation:
Step 1: Analyze problem statement.
Step 2: Evaluate options.
Step 3: Select verified answer.