Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
For loop problem
#1
Hey

Why doesn't this work:
PHP Code:
#include <iostream.h>
int main() {
   
int x 0;
   
int i;
   for (
1<= 100i++)  {
     
+= i;
   }
   
cout << << endl;
   return 
0;


For 'x', I should be getting the same as 'i' (1 going down to 100) but I get 5050.

Does anyone know what the problem is?

P.S - I'm learning from a book, so any mistakes are Jeff Cogswell's fault.
Reply


Messages In This Thread
For loop problem - by GeneralOJB - 12-15-2009, 02:12 PM
RE: For loop problem - by Gaijin - 12-15-2009, 02:20 PM
RE: For loop problem - by GeneralOJB - 12-15-2009, 02:35 PM
RE: For loop problem - by Gaijin - 12-15-2009, 02:38 PM
RE: For loop problem - by GeneralOJB - 12-15-2009, 02:48 PM
RE: For loop problem - by Gaijin - 12-15-2009, 04:14 PM
RE: For loop problem - by Brainless Control - 12-15-2009, 02:52 PM
RE: For loop problem - by GeneralOJB - 12-15-2009, 03:02 PM
RE: For loop problem - by Brainless Control - 12-15-2009, 03:13 PM
RE: For loop problem - by GeneralOJB - 12-17-2009, 03:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why doesn't this loop work? nevets04 5 1,158 12-11-2009, 03:38 AM
Last Post: Sagittarius

Forum Jump:


Users browsing this thread: 1 Guest(s)