0

Explain this code please

Explain this code, please... https://code.sololearn.com/cj9m3OJZLXK2/?ref=app

9th Jul 2019, 7:33 PM
Sreejith P
Sreejith P - avatar
4 Antworten
+ 1
Sree so: Printf uses stack, which means that your last argument is treated first then second last argument at second place... and the first argument is treated at last. So now I'm gonna explain you the execution of your code here: Step 1: last argument is treated first. pre-increment,++a, becomes 5 but that last is not assigned value of 5 yet. It's waiting for whole statement to execute then assign value. Yet we get value of a as 5. Step 2: a will be evaluated next. Here we don't have incrementation, so a will remain the same, and 5 (step 1) is printed out. We still have value to be 5. Step 3: post-increment,a++, will be evaluated next. Value of a will be turned to 6, and 6 (step 2) is printed out. So it's time for pre-increment to do its assignment of value, so last argument gets value of 6. I hope you understood😉👌
10th Jul 2019, 9:38 AM
Dejan Francuz🥇
Dejan Francuz🥇 - avatar
0
please use the search bar, this question have been answered several times, just search with the keyword
9th Jul 2019, 7:51 PM
✳AsterisK✳
✳AsterisK✳ - avatar
0
i++ means it prints i and then increases, ++i means it increases i and then prints 👌
9th Jul 2019, 10:20 PM
Dejan Francuz🥇
Dejan Francuz🥇 - avatar
0
I know prefix and postfix but I've some doubts in this output...can you please explain the output of this code..and why this same program gives different output in C++ Dejan Francuz
10th Jul 2019, 7:50 AM
Sreejith P
Sreejith P - avatar