what is the output: x=15; printf("%d %d %d",x==15,x=30,x==30); | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is the output: x=15; printf("%d %d %d",x==15,x=30,x==30);

21st Nov 2019, 12:59 PM
Amit Dubey
Amit Dubey - avatar
10 Answers
+ 5
Test it in multiple compilers, you will have different output. Even Code Playground warned you the risk of undefined behaviour. Another case of sequence point violation it seems.
21st Nov 2019, 3:11 PM
Ipang
+ 2
What you expecting output would be?
21st Nov 2019, 1:04 PM
Jayakrishna 🇮🇳
+ 2
Amit Dubey you have a code playground to check the answer. So kindly use it. If you do not understand then ask your doubt here.
21st Nov 2019, 1:07 PM
Avinesh
Avinesh - avatar
+ 2
Then You are right... You expected the right.. may vary on different compilers. here order of evaluation as you expecting happening is right to left so the output is 0 30 0. edit: Amit Dubey your wel come .
21st Nov 2019, 1:42 PM
Jayakrishna 🇮🇳
+ 2
yes you are right ipang😊 but i also used it in code blocks, then in cpp droid ..the output is same..
22nd Nov 2019, 12:56 AM
Amit Dubey
Amit Dubey - avatar
+ 2
I got 1 30 1 in CDroid Amit Dubey And in Code Playground I got that sequence point warning. What can I say? 😁
22nd Nov 2019, 3:38 AM
Ipang
+ 2
Amit Dubey May be run it multiple times on different compilers, you would see different results just as Ipang said.
22nd Nov 2019, 3:51 AM
Avinesh
Avinesh - avatar
+ 1
If you just want to know the output, just test it out yourself, that's how one learns. If you're looking for some explanation, please be more clear about it. Happy testing!
21st Nov 2019, 1:17 PM
Gonçalo Magalhaes
Gonçalo Magalhaes - avatar
+ 1
expecting output : 0 30 0
21st Nov 2019, 1:38 PM
Amit Dubey
Amit Dubey - avatar
0
thanks
21st Nov 2019, 1:43 PM
Amit Dubey
Amit Dubey - avatar