What does int i = j < 10 ? 5 : 15; mean? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What does int i = j < 10 ? 5 : 15; mean?

29th Jul 2017, 6:12 AM
Isack Cyprian
Isack Cyprian - avatar
5 Answers
+ 10
// similar to int i; if (j < 10) i = 5; else i = 15;
29th Jul 2017, 6:50 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
It's like a shorter if-else-statement. You wamt to assign a value to the variable i here. The value depends on a statement standing in front of the question mark. If it's true, the first value is assigned (5), if not, the second one (15).
29th Jul 2017, 6:16 AM
Jonas Schröter
Jonas Schröter - avatar
+ 1
good
29th Jul 2017, 11:00 AM
Ndohele
+ 1
i is 5 and 15
29th Jul 2017, 11:00 AM
Ndohele
+ 1
and j is 10
29th Jul 2017, 11:00 AM
Ndohele