increment problem

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include<iostream>

using namespace std;
int main(){
 
 int x,m,n;
 cout<<"Enter m:";
 cin>>m;
 cout<<"\nEnter n:";
 cin>>n;
 
 x= ++m + ++n;
 
 cout<<"THE value of X :"<<x;
 
 return 0;  
 
 }

The output I get is
  Enter m :10 
                             Enter n: 15
                             THE value of X : 27 


But the result on my textbook is saying m=11,n=16 x=26

Is it OK?
Last edited on
11 plus 16 is definitely 27. As long as you don't try to change the same variable twice, there is no uncertainty.
yes thanks :D but the answer shows in textbook is 26..that's why I am confused
Topic archived. No new replies allowed.