Assume you have a file called studentstxt that contains grad
Assume you have a file called \"students.txt\" that contains grades of 500 students, write C++ program to read these grades and display the averages and how many students fail (the failing grade is less than 60).
Solution
#include<cmath>
#include<iostream.h>
#include<iomanip.h>
#include<string.h>
int main()
{
double average,count,n;char name[50];int fail=0;
ifstream input;
input.open(students.txt);
if(input.is_open())
{
while(input.good())
{
do(!input.eof())
{
input>>n;
total=total+n;
count+++;
if(total<60)
{
fail++;
}
}
average=total/count;
count<<\"average\"<<\"fail\"<<endl;
}
input.close();
}
return 0;
getch();
}

