+ 4

How a conditional operator works???

(a<b?a:b)

27th Oct 2017, 12:21 AM
Nishant Magarde
Nishant Magarde - avatar
3 Respuestas
+ 33
int x = (a <b ) ? a : b ; //x will be the number which is smaller , //if a is smaller than b , then x will be a ... else b //even if a = b , then also x will be b
27th Oct 2017, 1:42 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 6
The a<b is the condition. If it is true then the result will be the first one which is a, otherwise th result will be b.
27th Oct 2017, 12:27 AM
Tan Yong Keong
Tan Yong Keong - avatar
+ 4
condition ? statement if condition is true : statement if condition is false
28th Oct 2017, 5:20 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar