Conditional operator in c++ with example

Conditional operator is alternative to simple if-else statement

Syntax:-

expr1 ? expr2 : expr3

Execution:-

expr1 is always evaluated, if results is true than expr2 is executed otherwise expr3 is executed.

Example:-

Program to find greatest number between 2


Previous Code:-
else-if statement

List Code:-
C++ Codes

Next Code:-
For loop

C++ Programs
List of c++ Programs

Leave reply

Add your comments here

Back to Top