I don't understand about increments | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

I don't understand about increments

17th Mar 2018, 12:28 PM
Badu
4 Answers
+ 6
First method int a=0; a++; cout<<a; //output:1 Second method int a=0; cout<<++a; //output:1
17th Mar 2018, 1:19 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 5
increments & decrements are the changing of an existing variable value by adding or subtracting a number to that value .. consider the following : int var = 1 ; var++; cout<<var; var -= 2 cout<<var; in the first cout statement it should output 2.. in the second cout it should output -1..
17th Mar 2018, 12:40 PM
Ashraf Al_Absi
Ashraf Al_Absi - avatar
+ 1
There are two things increment and decrement..... increment is like a++; which is equal to a=a+1; decrement is like a--; which is equal to a=a-1;
17th Mar 2018, 12:34 PM
Mohd Zaki
Mohd Zaki - avatar
+ 1
tnx
18th Mar 2018, 8:17 AM
Badu