0
what would be the output of this code and how??
#include <stdio.h> int main() {int exp=1?0:2?3:4; printf("%d",exp); return 0;}
3 Answers
+ 3
You know ternary operator? a short form of if...else conditionals ...
<exp> = ( 1 ? 0 : ( 2 ? 3 : 4 ) )
Does this look clearer?
+ 3
Well you know a non-zero number is considered truthy in C/C++ right?
So that part was like "is 2 a truthy value? if so then give back 3, else give back 4"
+ 1
yes Ipang but i donno how i should solve this part (2 ? 3 : 4)