+ 1
What makes --?
I don't understand what -- do I know that x=-1 =1 and x-=1 is 1 too but what do --? when you can German pls in German thanks for help
11 Answers
+ 1
i cant't german, but...
x=5
x--
output...x=4
x--
output...x=3
+ 3
@Thore (re: Der erste Teil der Frage / regarding the first part of the question):
x = -1 ---> im wirklichkeit, x ist: -1 (in actuality, x is -1)
x -= 1 ---> x weniger oder "minus" einen / subtrahiert einen vom aktuellen Wert von x (x less or "minus" 1 / subtracts 1 from the current value of x)
* Englisch ist meine Muttersprache (English is my mother tongue)
+ 2
thanks this help me very much
+ 2
Another example:
for(int floor = 3; floor > 0; floor--)
{
cout << "Current floor is" << floor << endl;
}
cout << "Now on ground floor";
+ 2
Danker. Nien know german
Sorry ;)
+ 2
and teach me german is
unterrichte mich in Deutsch
:)
+ 1
;D
+ 1
by the way...teach me german xD
+ 1
:O
+ 1
by the way is in german nebenbei
+ 1
x++ or x-- is known as postfix
++x or --x is known as prefix
Difference between postfix and prefix:
int x = 5;
// Postfix
int y = x++; // First is the assignment (y = x), then the x variable is incremented by one (x = x + 1), so first y = x = 5, then x = 6
// Prefix
int x = 5;
y = ++x; // First x is incremented, then is the assignment, so x = 5 + 1, then y = x = 6