Computer Science Canada Question For Class... |
Author: | Flikerator [ Fri Oct 14, 2005 9:56 pm ] |
Post subject: | Question For Class... |
We got a booklet of questions today and I finished them all in like 20 mins... There was a question that wanted to enter an unknown length of numbers from the user not a file. It then wanted the sum, average, highest, and lowest numbers. I used a flexible array, it was very easy that way. How would you go about doing that? Help me get in your mind XD |
Author: | [Gandalf] [ Fri Oct 14, 2005 10:36 pm ] |
Post subject: | |
What? Please rephrase that, because to me it made absolutely no sense You said you did it, and then you are asking how to do it?? |
Author: | Cervantes [ Sat Oct 15, 2005 7:20 am ] |
Post subject: | Re: Question For Class... |
Flikerator wrote: We got a booklet of questions today and I finished them all in like 20 mins... There was a question that wanted to enter an unknown length of numbers from the user not a file. It then wanted the sum, average, highest, and lowest numbers.
I used a flexible array, it was very easy that way. How would you go about doing that? Help me get in your mind XD Perhaps he's asking how to do it without using flexible arrays? In that case, keep a running tally of the sum and the number of numbers inputted so far. Also have a variable called lowest and another called highest that begin at maxint and minint, respectively. If the number inputted is > lowest, make lowest equal to that number. Similarly for highest. |