+ 5
How to output 3 when you enter 5 and output 5 when input is 3 without if, switch in one row code?
without if, switch ...
4 Answers
+ 12
o_o Srsly? I guess there might be a way you can do it with bitwise operators or something, but I dunno how to do that!
+ 11
Use the ternary operator, ?:. Nest them together like this:
cout << (input == 5) ? "3" : ((input == 3) ? "5" : "something else")))
+ 5
cin>>n;
cout << 8-n;
😅😅
+ 2
without ternary operator 😊