Code:
Code://*Hira Daud // regn no=83 //BICSE 4-A*/ #include<iostream> #include<string> using namespace std; struct student { float sum; float numbgrade; char course; char section_number; double reg_no; string name; int progass[4]; int test[4]; int homeass[4]; float progav; float testav; float homeav; }; void swap(int *,int *); bool ascending(int ,int ); void bubble(float ,const int size,bool (*compare)(int,int)); void lettergrade(float *); //prototypes int main() { double testwgt,homewgt,progwgt; testwgt=0.6; homewgt=0.2; progwgt=0.2; const int a=40; student student1[a]; for (int i=0;i<a;i++) { cout<<"please enter your name\t:"; cin>>student1[i].name; cout<<"\nenter your section number\t:"; cin>>student1[i].section_number; cout<<"\nenter your registration number\t:"; cin>>student1[i].reg_no; cout<<"plz enter ur crs identifier\n"; cin>>student1[i].course; student1[i].testav=student1[i].progav=student1[i].homeav=student1[i].sum=0; //initializing for(int j=0;j<4;j++) { cout<<"enter the marks of ur tests\n"; cin>>student1[i].test[j]; student1[i].testav+=student1[i].test[j]; cout<<"enter the marks of ur programming asssignments\t\n"; cin>>student1[i].progass[j]; student1[i].progav+=student1[i].progass[j]; cout<<"enter the marks of ur home assignments\n\t"; cin>>student1[i].homeass[j]; student1[i].homeav+=student1[i].homeass[j]; }//end of the nested loop student1[i].testav/=4; student1[i].homeav/=4; student1[i].progav/=4; student1[i].sum = student1[i].testav+student1[i].progav+student1[i].homeav; if(student1[i].sum>1) cout<<"there s some error"<<endl; else cout<<"calculate the numeric grade"<<endl; for(int i=0;i<40;i++) { student1[i].numbgrade=testwgt*student1[i].testav+progwgt*student1[i].progav+homewgt*student1[i].homeav; lettergrade(&student1[i].numbgrade); } }//end of for loop bubble(student1[i].numbgrade,a,ascending); cout<<"the highest numeric grade achieved by the student\n"<<student1[39].numbgrade<<endl; cout<<"the lowest grade is\n"<<student1[0].numbgrade; return 0; } void lettergrade(float *grade) { if(*grade>93&&*grade<100) cout<<"ur grade s A"<<endl; else if (*grade>85&&*grade<92) cout<<"ur grade s B"<<endl; else if(*grade>77&&*grade<84) cout<<"ur grade s C"<<endl; else if(*grade>70&&*grade<76) cout<<"ur grade s D"<<endl; else cout<<"ur fail"<<endl; } //function definition for calculating the letter grade void bubble(int stud[],const int size,bool (*compare)(int,int)) { for (int a=1;a<size;a++) { for(int b=0;b<size-1;b++) if((*compare)(stud[b],stud[b+1])) swap(&stud[b], &stud[b+1]); } } void swap(int *c,int *d) { int hold=*c; *c=*d; *d=hold; } bool ascending(int p,int q) { return q<p; }



LinkBack URL
About LinkBacks


