once you have all the numbers, read the first one. by definition, it is the smallest. save it in a variable called something like currentSmallest. then, look at each successive number in turn. if it is smaller than what you have saved, save it in currentSmallest. when you have scanned all the input numbers, currentSmallest will be holdings the value you want.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I think we should start responding to requests for the community to do someone's homework in the style of an obfuscated code contest like the International Obfuscated C Code Contest. The student may learn something trying to figure out what the code does and would be less likely to just turn that code in lest the instructor ASK how the code works. I wish I had the time to obfuscate printing out a copyright notice or something of that nature. Just in case a student resorted to outright plagarism.
Joe, do you think i gave too much away? i was trying to be general enough (i figured this was probably a homework, so i didn't post any actual code). i remember sometimes the homeworks are so overwhelming - you can't write any code, because you don't know the algorithm, but you can't test an algorithm because you don't know how to write the code... i can try and be more vague in the future if you think this was too much... thanks f
Originally posted by Thomas Paul: No, I think your answer was perfect.
Agreed. To be clear, I was typing at the same time Fred was, so my comments don't reference his. I was trying to think of a way to respond to homework questions other than the Boilerplate Homework Response (i.e. try to write some code and ask a specific question. . .).