I'm trying to create a C program which keeps taking in integer values until the number 0 is entered (the sentinel value). The "taking in" part is easy, but confused about evaluating the extrema. Once I can figure out how to do one way, then the other way is easy - just reversed. So, let's say, for now, that we want to calculate the minimum of all the integers entered. I understand the algorithm of how I might want to go about this. Basically, just keep updating a variable named
min if the number entered is lower than the stored value of min. But, all this starts somewhere. How do I start it? There has to be a "stored value of min" to updated the "stored value of min". For example, let's say the user enters:
Then, the answer should be outputted as 1, since it is the minimum of all the non-sentinel values entered. Now, how do we store the first numbered, and the first number only, as the min and then keep updating. I might kick myself when I get the response, but I just seem stuck here. Any slight bit of help - even a hint - would be greatly appreciated! Thanks in advance. :)