+ 1

[SOLVED] Conditional operator

I couldn't able to assign 10 to x or y #include <iostream> using namespace std; int main() { int value , x , y ; cin >> value ; value > 500 ? x : y = 10 ; cout << x ; return 0; }

4th Jun 2018, 2:13 AM
Aveek Bhattacharyya
Aveek Bhattacharyya - avatar
2 ответов
+ 8
Replace value > 500 ? x : y = 10 ; with value > 500 ? ( x = 10 ) : ( y = 10 )
4th Jun 2018, 2:21 AM
DAB
DAB - avatar
+ 1
Thanks , it solved my problem
4th Jun 2018, 2:24 AM
Aveek Bhattacharyya
Aveek Bhattacharyya - avatar