View Single Post
  #7   Spotlight this post!  
Unread 23-01-2004, 18:28
mtrawls's Avatar
mtrawls mtrawls is offline
I am JVN! (John von Neumann)
#0122 (NASA Knights)
Team Role: Programmer
 
Join Date: Mar 2003
Location: Hampton, VA
Posts: 295
mtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to behold
Send a message via AIM to mtrawls
Re: is there a problem with...

Quote:
Originally Posted by AlphaOmega870
for ( n = 1; n =< 150; n++; )
this line of code?
I continuosly get a syntax error with this line and can find no problem with it. Thank you in advance.
Err ... aside from the mentioned extra semicolon at the end, unless my memory has become severly skewed, I do believe you mean "<=" for less than or equal to, as opposed to "=<". But why such wird code? I mean, really, who starts counting at 1? (Besides normal people, of course

Traditionally, though, you'd say
Code:
for (n=0; n < 150; n++)
This is because C starts indexing at 0, like most sane languages. You can also avoid having an equal sign in the for loop. I suppose it is a matter of taste, though ... (and what you do with n within the loop)