The ++ increment operator increases value only by one
for (int i = 0; i < 10; i++)
To increase twice:
for (int i = 0; i < 10; i+=2) { Console.Write("Enter Score{0}: ", i); }
Read more: Increment (++) and Decrement (--) Operators
| If | Equivalent Action | Return value | | variable++ | variable += 1 | value of variable before | | | | incrementing |
The following row:
Console.Write("Enter Score{0}: ", i + 1);
increases the value of i by plus 1 but that is not stored into i. It is like writing:
int b = i+1; // i is not affected. New value never stored back into i Console.Write("Enter Score{0}: ", b);
Any of the following ways will increase value by 2:
//Option 1 for (int i = 0; i < 10; i +=2) //Option2 Console.Write("Enter Score{0}: ", i++); //Option3 i = i+1; Console.Write("Enter Score{0}: ", i);