![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Re: While loop
First, get a decent editor, or if you're using one, set your preferences so that tabs are converted to spaces. Your formatting sucks, even after I added code tags for you.
Secondly, I don't know why you're using a generic "isDivisibleBy" function, when your ealier stated requirement was divisible by 5, and divisible by 2. The mod operator would be much more efficient. That's okay, though. What isn't okay is nesting one function inside another. If you're going to use it, put it outside main. Once you fix that and clean things up a bit, we'll have another look. Incidentally, are you reading your error messages? Just curious.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#12 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 825
Rep Power: 4
![]() |
Re: While loop
You only increment i if the number is divisible by 5. Since 1 isn't evenly divisible by 5 your loop never gets off 1.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Value of index incorrect after loop | aznluvsmc | C | 13 | Nov 6th, 2005 9:47 PM |
| for loop and while loop - help | mguarin | C | 7 | Oct 24th, 2005 8:22 PM |
| ASCII conversion loop difficulty | crmpicco | Visual Basic | 2 | May 3rd, 2005 1:55 PM |
| WinSock accept() hangs program in Do loop... | layer | C++ | 5 | Apr 29th, 2005 11:28 AM |
| Timing loop problems | badbasser98 | C++ | 11 | Mar 10th, 2005 8:30 PM |