Search:
Forum
Beginners
modulu
modulu
Jan 1, 2016 at 1:27pm UTC
malkews
(4)
Write your question here.
1
2
int
x; x= (x%2)?1:2;
what does this do "?1:2" please help????
Jan 1, 2016 at 1:31pm UTC
keskiverto
(10402)
Ternary operator:
http://en.cppreference.com/w/cpp/language/operator_other
Jan 1, 2016 at 3:43pm UTC
Stalker
(77)
It is a ternary operator used for short if/else cases. The above code can be converted to:
if(x % 2)
x = 1;
else
x = 2;
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs