Increment and Decrement Operators Insert the appropriate val

Increment and Decrement Operators. Insert the appropriate value of x and y. Then rewrite the following as pre increment or post-increment operators. int x = 0; cout

Solution

Question 1:
int x=0;     x: 0
cout<<x;     x: 0
x=x+1;       x:1

Rewrite : x++;

Question 2:
int x=3,y=0; x:3
           y:0
x=x+1; x:4
y=x; y:4

Rewrite : y=++x;

Question 3:
int x=3,y=0; x:3
           y:0
y=x; y:3
x=x+1; x:4

Rewrite : y=x++;

Question 4:
int x=0; x=0
int y=x; y=0
x-=1; x=-1

Rewrite :y=x--;

Question 5:
int x=0,y=3;x:0
           y:3
x+=1; x:1
y-=1; y:2
cout<<x<<\"\"<<y; x:1
y=2
Rewrite: cout<<++x<<\"\"<<--y;

 Increment and Decrement Operators. Insert the appropriate value of x and y. Then rewrite the following as pre increment or post-increment operators. int x = 0;

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site