Question

Guys , i have a question . Can we compare 2 numbers without using while, for, if, else, etc. It is possible ?
The short answer is yes.

However, it depends what you want to do next. You could just do something like this:
 
    5 < 3;
Hardly very useful.

Or perhaps something like
 
    bool result = 7 == 4;
which is potentially useful - you could later do something with the variable result, such as print it out.

Or if you want to take some action after the compare, then the conditional ternary operator ( ? ) is a possibility - but that really fits in a very specific context and isn't a general-purpose replacement for anything else.
http://www.cplusplus.com/doc/tutorial/operators/
Last edited on
Topic archived. No new replies allowed.