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++...

13th Mar 2021, 4:55 PM
hashem hubaish
hashem hubaish - avatar
8 Réponses
+ 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.
15th Mar 2021, 4:57 AM
Illa Bahadur Darlami Magar
Illa Bahadur Darlami Magar - avatar
0
Paste your code into playground and share it here
13th Mar 2021, 6:41 PM
Michal Doruch
0
If I have a code I wasn't asking you 😭
13th Mar 2021, 7:37 PM
hashem hubaish
hashem hubaish - avatar
0
Then clarify your problem, try doing it yourself, and ask for help when you will have tried solving it yourself
13th Mar 2021, 7:40 PM
Michal Doruch
0
I'm studying. IT l am at beginning
13th Mar 2021, 8:02 PM
hashem hubaish
hashem hubaish - avatar
0
Ok thank you I'll try
13th Mar 2021, 8:02 PM
hashem hubaish
hashem hubaish - avatar
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
17th Mar 2021, 3:27 PM
hashem hubaish
hashem hubaish - avatar
- 1
I don't have a time
13th Mar 2021, 8:01 PM
hashem hubaish
hashem hubaish - avatar