Largest of two numbers using conditional operator

Largest-of-two-numbers-program-in-using-conditional-operator

Introduction:

Write a C Program to find the largest of two numbers using the conditional operator in C Language.

The program should accept two numbers and find the largest. The program should use only the C Language conditional operator.

Examples:

Input:

Output:

Syntax Conditional Operator in C:

Condition ?  TrueExpression : FalseExpression

If the Condition is True then the TrueExpression will be executed.

Similarly, If the Condition is false, Then FalseExpression will be executed.

We can have nested conditional Operators in C Langauge.

We have discussed the conditional operators in detail in the following post – C Language: Conditional Operator (? 🙂 Tutorial | Ternary Operator/ Conditional operator tutorial with Examples – SillyCodes

Largest of Two numbers in C Program :

Largest of Two numbers Program Output:

Related Articles:

Venkat

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

3 Responses

  1. […] have looked at the Program to find the Maximum of two numbers using the if else statement and conditional statements. In today’s article, We are going to write a C Program to find the maximum of two numbers […]

  2. […] C Program to Calculate Largest of two numbers using conditional operator […]

  3. […] C Program to Calculate Largest of two numbers using conditional operator […]

Leave a Reply