Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 28th, 2007, 1:17 PM   #11
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Oct 28th, 2007, 9:25 PM   #12
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 825
Rep Power: 4 The Dark is on a distinguished road
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.
The Dark is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:42 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC