- 1

What do % and (a>b)? a:b mean?

So the first question is: what is %? Ex: a%b The 2nd question is: I know what (a>b)? Means but what is a:b??? Thanks...

27th Nov 2017, 3:44 PM
Noor al-Rajab
Noor al-Rajab - avatar
4 Respuestas
+ 4
A%B = X: 5%2 = 1; % stands for the modulus operator, what it basically does, is give you the remainder of division between A and B. std::string exampleVariable = (true) ? "Cool, it's true." : "Aww, it's false"; This syntax expanded is: std::string exampleVariable; if (true) { exampleVariable = "Cool, it's true."; } else { exampleVariable = "Aww, it's false."; } So, basically the value on the left side of the " : ", is the value that will be represented if the boolean is true.
27th Nov 2017, 3:55 PM
eRosz
eRosz - avatar
+ 1
5 % (modulo) 3 is 2 because it's one with a rest of 2. 8 % 4 = 0 12 % 7 = 5 100 % 3 = 1 x = (condition) ? a : b; is the same as if (condition) x = a; else x = b;
27th Nov 2017, 3:56 PM
Timon Paßlick
0
Thank you!
27th Nov 2017, 3:58 PM
Noor al-Rajab
Noor al-Rajab - avatar
- 1
No problem. Please mark your question as solved to save other users time. ( :
27th Nov 2017, 4:00 PM
Timon Paßlick