Ahem, I suggested it first!
Actually it's a well-known solution, so neither of us deserves praise . . . .
Ahem, I suggested it first!
Actually it's a well-known solution, so neither of us deserves praise . . . .
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Ah, it got lost somewhere in the thread! I see it now.
You outsmarted as all Actually, I didn't know there was such an optimization. Well, I don't really work with loops that way. Often... anyway... I think...
lmao.. found my stupid mistake..
thanks guys..
one more quick questions guys
how can i make a program reject a negative value from being stored in array. e.g if a user inputs a negative value, how can i display a message that will tell the user to enter a positive value.
Guess. Maybe something along the lines of
- Get a number from the user.
- If the number is negative:
- Print an error message.
- Get another number from the user.
- Go to step 2.
- Viola! You have your number.
That can be simplified, of course, for example if you use a do-while loop instead . . . but try that and see what happens.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.