Largest of two numbers using conditional operator

Spread the love

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...

Leave a Reply