Is increment operator used to increment a number by one?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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++ ??

16th Aug 2019, 2:55 PM
D Nachiketh
D Nachiketh - avatar
3 Answers
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
16th Aug 2019, 4:01 PM
_rk
_rk - avatar
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
16th Aug 2019, 3:54 PM
_rk
_rk - avatar
0
What if that I wanted to increment a number by 3 or 4 times
16th Aug 2019, 3:57 PM
D Nachiketh
D Nachiketh - avatar