0
Is increment operator used to increment a number by one??
Like in C we write x+2 to increment it twice is this applicable in c++ ??
3 Réponses
0
Just use addition operator.
If X is a variable then,
X+2
Will add up 4 to it.
dont confuse between a addition operator and increment operator.
X++ is equivalent to
X=X+1
0
As mentioned in your question +(x+2) is not an increment operator.
It is a arithmatic addition operator.
C, c++, java etc.. use increment operator ++ and -- .++ Increments the value of a variable by 1.
Increment operator comes in 2 forms
1.pre-Increment
2.post-Increnent
0
What if that I wanted to increment a number by 3 or 4 times