0

i dont understand decreament??

28th Dec 2016, 6:59 PM
Chanju Singha
Chanju Singha - avatar
5 odpowiedzi
0
It means reduce. So if you see i--(which can also be written as i=i-1) means reduce i by 1 after you finish this statement. Or if you see --i, it means, reduce i by 1 first then finish this statement
28th Dec 2016, 8:10 PM
Flo
0
an example for decreament
29th Dec 2016, 7:50 PM
Chanju Singha
Chanju Singha - avatar
0
int a = 2; if(a < 5) a--; cout << a; this will print 1
29th Dec 2016, 10:13 PM
Flo
0
and example of --a
30th Dec 2016, 2:10 AM
Chanju Singha
Chanju Singha - avatar
0
int a = 2; if(a < 5) cout << a--; cout << a; the code above will print 2 then 1 int a = 2; if(a < 5) cout << --a; cout << a; This code will print 1 then 1.
30th Dec 2016, 9:23 PM
Flo