0
What is mean of += or i++?
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. ;)
+ 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 ++.
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;