hamburger menu
All Coursesall course arrow
adda247
reward-icon
adda247
    arrow
    arrow
    arrow
    What will be the output of the following C program?
    Question



    What will be the output of the following C program?

    A.

    5

    B.

    10

    C.

    15

    D.

    0

    E.

    Compilation Error

    Correct option is C

    The program uses nested ternary operators to evaluate conditions step by step:
    1. (a > b) checks if 5 > 10, which is false.
    2. Since the first condition is false, the second part of the ternary operator is executed: ((a > c) ? a : c).
    3. (a > c) checks if 5 > 15, which is also false.
    4. Thus, the value of c, which is 15, is assigned to result.
    Finally, the program prints 15.
    Important Key Points:
    1. Nested ternary operators are evaluated from left to right, based on their conditions.
    2. The ternary operator ensures concise code but can become hard to read when nested.
    3. Debugging ternary operations can be simplified by breaking them into smaller expressions.
    Knowledge Booster:
    · Condition 1: (a > b) evaluates as false, so the second branch is executed.
    · Condition 2: (a > c) evaluates as false, so the value of c is selected.
    · Result: 15 is printed.

    Free Tests

    Free
    Must Attempt

    RBI Asst Prelims 2026: Quant Advance level Test 01

    languageIcon English
    • pdpQsnIcon35 Questions
    • pdpsheetsIcon35 Marks
    • timerIcon20 Mins
    languageIcon English
    Free
    Must Attempt

    RBI Asst Prelims 2026: Reasoning Advance level Test 01

    languageIcon English
    • pdpQsnIcon35 Questions
    • pdpsheetsIcon35 Marks
    • timerIcon20 Mins
    languageIcon English
    Free
    Must Attempt

    NABARD Development Assistant Mains 2026 Full Mock Test -01

    languageIcon English
    • pdpQsnIcon150 Questions
    • pdpsheetsIcon150 Marks
    • timerIcon105 Mins
    languageIcon English
    test-prime-package

    Access ‘IBPS SO IT Officer’ Mock Tests with

    • 60000+ Mocks and Previous Year Papers
    • Unlimited Re-Attempts
    • Personalised Report Card
    • 500% Refund on Final Selection
    • Largest Community
    students-icon
    383k+ students have already unlocked exclusive benefits with Test Prime!
    Our Plans
    Monthsup-arrow