File read, select, average.

Pages: 12
I'm off too, this should finish you up...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
	while ( file.good() )
	{
		file >> InPut;
		cout << "The number of elements in this group is " << InPut << endl;
		cout << "The data in this group is: ";
	
		for (int i=0; i <InPut; i++)
			{
				file >> nextInt;
				total=total+nextInt;
				cout << nextInt << " ";
			}
			
		cout << endl << "Average = " << total/InPut << endl << endl;  // Sum divided by InPut
		total=0; // Reset Total
	}
Lookin good. I actually almost had all of this before you posted it. Thank you for the lesson :) See you next time!
Last edited on
Topic archived. No new replies allowed.
Pages: 12