Showing posts with label ternary operator. Show all posts
Showing posts with label ternary operator. Show all posts

Thursday, January 21, 2016

C/C++ language. A funny challenge: sorting numbers without using arrays

From programmr.com: 

"Write a program which accepts 3 integers and sort them in ascending order."

Of course, we can use the ternary operator or some if/else statements in order to find the largest and smallest of the three numbers, respectively.

Once done that, we need to find the intermediate value using if/else statements.

The code and the print screen: