+ 1

What does it do?

what does this line of code do in c++?can you please explain IN DETAIL cout<<Remainder < 0 ? Remainder+(Base*-1) :Remainder; //Remainder and Base are defined variables...this is a base convertor code.

25th Jan 2017, 7:35 PM
JustALearner
JustALearner - avatar
1 Answer
+ 1
Remainder < 0 ? Remainder+(Base*-1) : Remainder This works almost like a if-else statement. a ? b : c; is like writing if(a){ b; } else { c; } (just that you can't use if-else like this within a cout) So if Remainder < 0 is true then it will cout << Remainder+(Base*-1); If Remainder < 0 is false it will cout << Remainder;
25th Jan 2017, 7:50 PM
Robobrine
Robobrine - avatar