By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,407 Members | 920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,407 IT Pros & Developers. It's quick & easy.

"successive missing page" program, who can solve?

P: 2
I have a question about my subject, Borland C programming..

a book is missing successive pages. the sum of these pages is the input, and the program determines which pages are missing (the pages are successive).
for instance;
the sum of missing pages is 15, so there are several answer:
- pages 1...2...3...4...5 (1+2+3+4+5 = 15)
- pages 4...5...6 (4+5+6 = 15)
- pages 7...8 (7+8 = 15)
- and page 15 its self,

but, the program takes the first answers for output.

I need some explanation about loop.
thx,
Mar 23 '07 #1
Share this Question
Share on Google+
3 Replies


sicarie
Expert Mod 2.5K+
P: 4,677
What sort of loop were you wanting an explanation of?
Mar 23 '07 #2

P: 2
what about if I use while... it seems easier I think
Mar 24 '07 #3

Roonie
P: 99
well, you can use any loop for any solution, so its a combination of personal preference and ease of coding that makes the decision.

why dont you try using a for loop that counts down . . . inside the loop try subtracting from the input to see if you can get a successive string of subtraction operations to work. then start the loop over again with a smaller number as its starting point.
Mar 24 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.