Answer:
Three ways to increase the value of variable are given below. To eleborate the answer, I am taking a variable x that need to be increase.
- x=x+1
- x++
- x+=1
Explanation:
There are three ways to increase the value of variable.
1. x= x+1
In this case, each time value of x (variable) is incremented and stored in that variable. This equation increase the value of x by 1 each time. For Example
if x=1
then in first iteration
x= x+1 = 2;
If we want to increase the value of x by more than 1, we can add that value with x, as x+2, x+3 and so on.
2. x++
This will increment the value of x by 1. If we use this equation multiple time in program, each time it will increase 1 in value of x.
3. x+=1
This also works same as equation 1. It will increment 1 in this form and can be changed with 2, 3 and so on.