Why can't I use x + 1 in for loop?
c
Solution
You need the value of `x` to change, or your loop will never terminate. When you have only `x + 1`, then at the end of the iteration, `x + 1` is computed, but its resulting value is discarded. The result of the expression is not stored any place. So `x` will remain zero, and `x <= 100` will remain true, and your loop will continue forever.
If you have any of the following:
x = x + 1
x += 1
x++
++x
the value of `x` itself is incremented. That's what you need.
Problem
I am working on that code, and I tried to use `x + 1` instead of `++x` and the result was infinite loop and zeros were printed on the screen. this is the code: ``` #include <stdio.h> int main(void){ int x; for(x = 0; x <= 100; x + 1) //instead of ++x printf("%d\t",x); return 0; } ``` I wondered this action.....why the compiler didn't produce such an error,,,, and what actually happens??!! and is `x++` is treated as `x += 1` ?!