+ 6

What is the output of this code and why?

#include <iostream> using namespace std; int main() { int p=8; cout<<++p; cout<<p++; return 0; }

6th Jun 2018, 4:51 PM
Ztujjar
Ztujjar - avatar
7 Answers
+ 13
Increment Operator learn about prefix and postfix https://www.sololearn.com/learn/CPlusPlus/1610/
6th Jun 2018, 4:54 PM
Burey
Burey - avatar
+ 3
what is the output please?
6th Jun 2018, 5:23 PM
Ztujjar
Ztujjar - avatar
+ 3
it’s clear now thank you so much for all of you 😀
6th Jun 2018, 6:14 PM
Ztujjar
Ztujjar - avatar
+ 2
9 9 ????
6th Jun 2018, 5:24 PM
KrOW
KrOW - avatar
+ 1
ztujjar You do realize you can put the code in the code playground to check the output? Btw its 99
6th Jun 2018, 5:47 PM
ReimarPB
ReimarPB - avatar
+ 1
both of cout will output 9. but if you add third cout it's gonna be 10. (9910)
6th Jun 2018, 5:55 PM
Owenizedd
Owenizedd - avatar