|
-
November 23rd, 2009, 07:33 PM
#1
Is this even possible? (don't need solution, just a yes or no)
Whats up guys. One of my questions on homework is as follows:
Write a value-returning function that contains a for loop that will find the sum of the integers from start to finish (start and finish are int variables passed to the function). (Example if start is 9 and finish is 12, then the function would return the sum of 9 + 10 + 11 + 12)
I don't see how this is possible using a for loop. Don't for loops only deal with counts and can't the testExpression only be an inequlaity? Ex. for(i=1, i<=10, i++)
Is it possible to do this with variables (start and finish) like the teacher said or should I just do a while loop? I'm a confused noob.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|