Question
#include #include #include using namespace std; class student { public: string year,um; int sid; float gpa; }; //function to read from file studentList.txt in struct
#include
class student { public: string year,um; int sid; float gpa; }; //function to read from file studentList.txt in struct student array //and return number of records presentin file int readData(student st[100]) { ifstream fin; int i=0; fin.open("StudentList.txt"); while(!fin.eof()) { fin>>st[i].sid; fin>>st[i].gpa; fin>>st[i].year; fin>>st[i].um; i++; } fin.close(); return(i-1); } //function to count and print number of students from each school //with GPA more than 4
void countTopper(class student st[100],int count) { int i,topper[4]={0,0,0,0}; for(i=0;i
void meanYearWise(class student st[100],int count) { int i,min=0,max=0; float total[4]={0,0,0,0},yearCount[4]={0,0,0,0},mean[4]; for(i=0;i for(i=1;i<4;i++) { if(mean[min]>mean[i]) min=i; if(mean[max] //main driver function int main() { int i=0,count; class student st[100]; count=readData(st); cout<<"Total number of students: "< This program when compiled is fine, but when i try to run it, Putty says "Segmentation fault(core dumped)"
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started