+ 1
I dot get it please help
I dot get it please help x++ and ++×
6 odpowiedzi
+ 4
++x is called preincrement while x++ is called postincrement
for instance
int x = 5, y = 5;
Console.WriteLine(++x)
Console.WriteLine(x)
Console.WriteLine(y++)
Console.WriteLine(y)
+ 4
in x++ value of x is increased after the operation.
for example:let x=4
y=3+x++
then the value of y will be 7
in ++x value of x increased before the operation.
for example:let x=4
y=++x+3
here value of y is 8
+ 1
Real world example:
We're making apple pies in which each apple pie requires 8 apples. We can't just shove whole apples into a pie, we should wash the apple, peel and cut the apple, and ensure we don't add too few or too many apples to ruin our recipe.
So my method of cooking would be washing, peeling and cutting the apples.
While using ++x or x++ to count each apple for accuracy.
If I were to count each apple before I did the above method I would use: ++x.
Else I'd do the method first and then count each apple: x++.
0
++x is pre increment means first increase the value then update the value
x++ is post increment means first update the value then increase the value
int x=5,y;
x++;
y=x;
cout<<y; //5
x=5
++x;
y=x;
cout<<y; //6
0
postfix and prefix , when you have x++ the instruction will work and then x will receive x+1 , in ++x , x will be incremented by 1 and the instruction will work with the new x value
- 1
hi