While ( x <= 100 )
total += x
++x;
any idea what's wrong with this code? I am so lost
While ( x <= 100 )
total += x
++x;
any idea what's wrong with this code? I am so lost
Please start using code tags!Code:while ( x <= 100 ) { total += x; ++x; // Or x++, in this case it does not matter; but at times the difference can become huge }
Besides the missing semi colon and the {} it worked. Was that your problem or are you not getting the results you expect?
one possibility (besides the fact that Enahs pointed out and that your while has a capitalized W) is that you didn't initialize x, so it's a value over 100 already.
Code:int x = 0; while(x <= 100) ...