+ 4
Can any one explian me why the output is all 1 for this code?
4 Antworten
+ 5
yes i agree with your answers Sanjay K Hegde and D⚽⚽⚽⚽7⃣7⃣7⃣ but what do u think the evaluation takes place from left to right or right to left? (that matters i guess)
+ 5
Rithesh R give challenge to Subramanya 😂
+ 2
You are using pre increment=> ++I, and post increment => I++. When using pre increment first you are changing the value and after that assign it to the variable. It's exactly the opposite in post increment first assign the value and after that change it. That's why your output is containing "1". You can see the explanation here www.quora.com/What-is-the-difference-between-pre-increment-and-post-increment-operator-in-C++-What-is-the-difference-between-code-a++-code-and-code-++a-code-in-C++
+ 2
Instead of assigning the value of x....just use
x++;
Then that prints one incremented value
int x=1;
x++;
printf("%d",x);
o/p: 2
same as decrement....
In your case you assigned the value to x ,So x is just increments and then returned to its original value.....thats y ur ans is 1