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
Video Solutions

SBI Clerk Mains 2026 Full Mock Test-01

languageIcon English
  • pdpQsnIcon190 Questions
  • pdpsheetsIcon200 Marks
  • timerIcon160 Mins
languageIcon English
Free
Must Attempt

SBI Clerk Mains MBT (29th October 2026 S1)- Based on Backlog Vacancies

languageIcon English
  • pdpQsnIcon190 Questions
  • pdpsheetsIcon200 Marks
  • timerIcon160 Mins
languageIcon English
Free
Must Attempt

SBI Clerk Mains 2026 : Reasoning Section Test - 01

languageIcon English
  • pdpQsnIcon50 Questions
  • pdpsheetsIcon60 Marks
  • timerIcon45 Mins
languageIcon English
test-prime-package

Access ‘IBPS SO IT Officer’ Mock Tests with

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