fstream

anyone i have a problem understanding this fstream my instructor gave me a problem regarding this topic
here it is!
write a program that will get the average of ten numbers.
the problem is how can i add and then divide it and then output it
the ten numbers are already given in type double
i dont know if i should use array!
plz help me understand
tnx!!!
Using an array would probably help. I'm assuming the numbers are in a file, right? So what is it, exactly, that's so confusing?
avg
30.5
11.3
12.3
8.6
9.9
27.5
8.3
12.6
3.9
9.8
this are the numbers that i will get the average!
he say's that the output will be on the file and on the screen!
Okay... so what do you need help with? What are you confused about?
can you give me an example of fstream program for this problem Plz so that i can have a way on doing other problems! :<
I'd rather not just give you the answer to the problem, but here's a fiveline pseudocode program of what to do:
[code]
open the file
read all of the data in the file into an array of size 10
set q = (array[0] + array[1] + array[2] + array[3] + array[4] + array[5] + array[6] + array[7] + array[9]) / 10
print q to the standard output
write q to the input file
[/quote]

So, where specifically is your problem?
Last edited on
Topic archived. No new replies allowed.