0

What is this called and its uses?

int even = 0, odd = 0; for(int i = 1; i<=100;i++){ even += (i%2==0)? i : 0; odd += (i%2==0)? 0 : i; } what is the "(boolean)? value : value;" called and what else can it be used for? I understand that if boolean is true it uses the value to the left of the colon and to the right if false.

9th Oct 2019, 11:45 PM
Odyel
Odyel - avatar
4 Antworten
+ 1
This kind of condition is called " operator condition"
10th Oct 2019, 12:23 AM
Mohammed Mizory
Mohammed Mizory - avatar
0
If the between parentheses check the condition, it gives a left value and if it does not take the right, then what is the problem?
10th Oct 2019, 12:16 AM
Mohammed Mizory
Mohammed Mizory - avatar
0
Mohammed Mizory is that all it does? Also what is this thing called?
10th Oct 2019, 12:18 AM
Odyel
Odyel - avatar
0
Oh ok thanks Mohammed Mizory
10th Oct 2019, 12:28 AM
Odyel
Odyel - avatar