0
Help me in C++ prefix and postfix I have the output just I well but it in description please
int x=12 then y=7 thes is the main. the output x=9, y=12, x=7, y=13, x=5, y=10 I need the code with ++x, x++,--x, x-- the same with y++...
8 Respostas
+ 1
See, if prefix and postfix (x++, --x) are nothing , they are just increasing the value by one or decreasing the value by one.
prefix:
++x: it means the value of x increase by one first than we perform the calculation ex: x=0 ; y=2+(++x); the y=3 and x=1;
x++: it means you do calculation first then increase the value of x by one ex: x=0; y=2+(x++); y=2 and x=1;
same for decrement:
--x: it means first decrease x by one then perform the calculation : ex: x=2; y=2+(--x) ; then y=3 and x=1;
x--; it means first perform the calculation and then decrease the value by one: ex: x=2; y=2+(x--) then y=4 and y=1;
I hope you got it.
0
Paste your code into playground and share it here
0
If I have a code I wasn't asking you 😭
0
Then clarify your problem, try doing it yourself, and ask for help when you will have tried solving it yourself
0
I'm studying. IT l am at beginning
0
Ok thank you I'll try
0
#include <iostream>
using namespace std ;
int main()
{
int x=12;
int y=7;
----x;
cout<<--x<<endl;
++++++y;
cout<<++++y<<endl;
cout<<----x<<endl;
y++;
cout<<y<<endl;
----x;
cout<<x<<endl;
cout<<------y;
}
Is there any one has another way to solution it
- 1
I don't have a time