How to use short-form if (conditional ternary operator) in C++

1 Answer

0 votes
#include <iostream>
 
int main()
{
    int a = 12, b = 20;
 
    int c = (a > b) ? a : b;
 
    std::cout << c;
 
    return 0;
}
 
 
 
/*
run:
 
20
 
*/

 



answered May 27, 2017 by avibootz
edited Sep 12, 2021 by avibootz

Related questions

2 answers 310 views
2 answers 317 views
1 answer 217 views
1 answer 221 views
...