CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

The simplest part won't work !!
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 03, 2006 4:43 pm     Reply with quote

Quote:
But just for my information would j = 0 to <=40 loop 40 times or 41 times ?


The following code will loop for 41 times. That's because the count
starts at zero, and it will run as long as the count is less than or equal
to 40. In other words, it will run for a count of 0 through 40, which is
a total of 41 times through the loop. (0, 1, 2, 3, ... 38, 39, 40).
Code:
for (k=0; k <= 40; k++)
     {
       // do something
     }


I don't normally use that construct ( <= ), because I want to see
instantly what the total loop count will be. If I do it as shown below,
starting at 0, and then using "less than" as the test, the total loop count
will be the number that I plug in on the right side of the test (40).

Code:
for (k=0; k < 40; k++)
     {
       // do something
     }
Guest








PostPosted: Tue Oct 03, 2006 4:54 pm     Reply with quote

Thanks for the tutorial PCM Programmer. That makes perfect sense. I promise I will remember this lesson learned !
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group