What is mean of += or i++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is mean of += or i++?

12th Dec 2019, 12:26 PM
umair shafiq
3 Answers
+ 10
Short answer: In C++, += means mathematical operators. variable++(i++) means post-increment operator. Know in detail: • Mathematical Operators: This type of operators are used to perform simple mathematical operations. Like addition, subtraction, multiplication etc... Example: int k=10; k += 8;//this will add k(10) with 8 and sum will be assigned to k. • Unary operators: ° Increment operators -pre-increment operator(++var) Before the next statement, the variable value will be increased. -post-increment operator(var++) After the execution of the next statement, the variable will be increased. Refer the link below to know more about types of operates in c++: https://www.studytonight.com/cpp/operators-and-their-types.php Hope you understood. ;)
14th Dec 2019, 2:22 AM
Vinay_GB
Vinay_GB - avatar
+ 2
It is simple you can jump from any number you want by using +=,like i+=3 or i+=2. One the other hand you can only increment a value by 1 using ++.
14th Dec 2019, 6:02 AM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
0
In C++ += works like: sum += 1; // which means sum = sum + 1; i++ just increments the value of i by 1 i.e i=1; i++; // i=2;
12th Dec 2019, 12:37 PM
Nabeegh Ahmed
Nabeegh Ahmed - avatar