Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 i need help with the logic
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
steven.yuan3




PostPosted: Wed Jan 27, 2010 6:06 pm   Post subject: i need help with the logic

this is the question i am working on, im not sure how to put it into a for or while loop. any ideas?


ss.jpg
 Description:
question
 Filesize:  74.51 KB
 Viewed:  128 Time(s)

ss.jpg


Sponsor
Sponsor
Sponsor
sponsor
jbking




PostPosted: Wed Jan 27, 2010 6:17 pm   Post subject: Re: i need help with the logic

Let's go over a few different points here. Consider a for loop for a moment. What do you want to be set at the start of the loop? What exit criteria should there be? What kind of increment should happen in the loop?

For example, to go from 1 to 10 in steps of 2, here is the C++:

code:

for (int i = 1; i < 10 ; i=i+2)
{
  // do something here with the i.
}


If you still need help, please specify where your difficulty is as I don't think the question is that hard, myself.
wtd




PostPosted: Wed Jan 27, 2010 11:12 pm   Post subject: RE:i need help with the logic

What's the same every time?

4

What changes?

The denominator and the use of addition or subtraction.

How does the denominator change?

It always increments by 2.

How does the arithmetic operator change?

It adds every other time around.
HRI




PostPosted: Wed May 05, 2010 7:46 pm   Post subject: Re: i need help with the logic

For the adding and subtracting part, -1 can be a very useful number if used in the right way.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: