0% found this document useful (0 votes)
22 views1 page

C++ Conditional Output Examples

The document contains C++ code snippets that utilize conditional (ternary) operators to evaluate and print messages based on age, points, birth year, and salary. The first snippet checks if age is 18 or older and if points are 500 or more to print corresponding messages. The second snippet evaluates the birth year and salary to determine if the output is 'Ok', 'High', or 'Not Ok'.

Uploaded by

rouge35.king235
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views1 page

C++ Conditional Output Examples

The document contains C++ code snippets that utilize conditional (ternary) operators to evaluate and print messages based on age, points, birth year, and salary. The first snippet checks if age is 18 or older and if points are 500 or more to print corresponding messages. The second snippet evaluates the birth year and salary to determine if the output is 'Ok', 'High', or 'Not Ok'.

Uploaded by

rouge35.king235
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

cout << (age >= 18 ? "OK\n" : (points >= 500 ?

"OK P\n" : "No P\n"));

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

int by = 72; // by => Birth Year


int s = 500; // s => Salary
cout << ( by > 80 ? ( s < 600 ? "Ok" : "High") : "Not Ok" );

You might also like