I have these question and I need some help from you :
Assume that the maximum number of students in a class is 50. Write a program that reads students' names followed by their test score from a file and outputs the following:

a. class average
b. Names of all the students whose test scores are below the class average, with an appropriate message
c. Highest test score and the names of all the students having the highest score

and this is my answer , and I dont know what is the problem with it , becuase the out put was not what I need the number on the screen like this -234567877.87 .

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{     double scores[50];
      double avg ;    
      double sum=scores[0],max = scores[0];
      string names[50];  
	  int count=0;
	  ifstream data;
	  data.open("in.txt");

	while (!data.eof()&&count<=50)

	{
		data>> names[count] >> scores[count] ;
					count++;
	}
		
	for (int m=1; m<count; m++)
	{

		sum+= scores[m];

			
			if (scores[m]>max)
			{
				max= scores[m];
				
			}
	}

	avg= sum/count;

	cout<<" class average is : "<<avg<<endl;
	cout<<"Students whose test scores are below the class average are :"<<endl;

	for (int n=0; n<count; n++)
	{
		if (scores[n]<avg)
			cout<<names[n]<<endl;
	}

	cout<<"Highest test score is : "<<max<<endl;
	cout<<"Students having the highest score are :"<<endl;

		for (int i=0; i<count; i++)
		{
			if (scores[i]==max)
			cout<<names[i]<<endl;
		}

      data . close ();
	return 0;
}

try this

.....
.....
int main()
{     double scores[50];
      double avg ;    
      
      string names[50];  
	  int count=0;
	  ifstream data;
	  data.open("in.txt");

	while (!data.eof()&&count<=50)

	{
		data>> names[count] >> scores[count] ;
					count++;
	}

        [B]double sum=scores[0],max = scores[0];[/B]

	for (int m=1; m<count; m++)
	{

		sum+= scores[m];

			
			if (scores[m]>max)
			{
				max= scores[m];
				
			}
	}
....
....
This question has already been answered. Start a new discussion instead.