Originally posted by: MAME
Originally posted by: Bacardi151
i have no experience with reading/updating other peoples code so i can't comment on that.
but sometimes you're forced to use while loops, if there's no fixed number of iterations, although in this case there is.
but imagine if the program was to ask for an integer input until the person put in a specific value which means quit. you wouldn't be able to implement that using a for loop.
instead you use an if statement to check if the specified exit value/string, is inputted and if it is, then you get out of the loop by a break statement. i really dont see the hardship in reading that.
FYI: for loops are while loops, thus anything a while loop can do, a for loop can as well
If you want to control input from a user, you could do:
while(input != (exiting input) )
There nothing overly horrible with your example, but it's just small scale. Think if the code was production level, say 1,000 lines of code for one loop. You don't want to trace every break statement and condition
I can speak with my teachers if you'd like, but assuming I pass my Art History final in 5 hours, I won't likely seem them in person ever again come wednesday