What is the purpose of using increment operator? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is the purpose of using increment operator?

I couldnt understand it at the very first glance but i made couple of experiments. The given loop tells that the user will keep putting values untill the number of values wont exceed 5 times. As it exceeds, the loop collapses and the program gets shut off. But Why we are using increment operator? How it is helping the user to keep adding values and defeating the purpose of loop " while " ?

1st Feb 2019, 6:18 AM
Muhammad Ahsan
Muhammad Ahsan - avatar
10 Answers
+ 3
Just short hand of a=a+1
1st Feb 2019, 10:00 AM
Ramshek Rana
Ramshek Rana - avatar
+ 2
I donā€™t understand you. Could you please supply your code?
1st Feb 2019, 6:32 AM
Rowsej
Rowsej - avatar
+ 1
Thansk you all but next time ill be more specific about my point.
1st Feb 2019, 4:04 PM
Muhammad Ahsan
Muhammad Ahsan - avatar
+ 1
Just short hand of i = i+1
15th Feb 2019, 3:01 PM
Khojo Afful
0
It is a fast way Do you know the difference between ++a and a++
1st Feb 2019, 7:36 AM
Gordon
Gordon - avatar
0
Thansk you all but next time ill be more specific about my point.
1st Feb 2019, 4:04 PM
Muhammad Ahsan
Muhammad Ahsan - avatar
- 1
To increase the value of a variable by one
11th Feb 2019, 4:59 PM
Swarnim Pal
- 2
increament operator is a unary operator used to increase the value of a variable they are of two pre-increment : increase value first then execute the statement ex : ++variable post-increment : execute the statement first then increase the value ex : variable ++ this is a part of for loop which is also called upgrade expression ex void main() { int a=10; clrscr(); printf(ā€œ%d\nā€,a++); printf(ā€œ%d\nā€,++a); getch(); }
1st Feb 2019, 3:35 PM
sree harsha
sree harsha - avatar
- 2
What anst
8th Feb 2019, 1:38 PM
A.Dawood Khan
- 4
hello muhhel
3rd Feb 2019, 5:38 PM
ismail El Ourrak
ismail El Ourrak - avatar