This is the simple C++ console program for beginners to compute the result of a Class. The program take take of the student, the marks in each subject and then compute the overall marks of the student and then calculate the average.You can change formula of calculation as per requirement.
Source Code
# include <iostream> #include <stdlib.h> #include <fstream> using namespace std; /* * uzair */ //Structure struct student { char name[20]; int grade[6]; }; //Struct Instance student stdInstance[50]; //Globel variables int i=0; int size=0; // Function Declearation int student_menu(); void add_student(); // Main int main() { cout<<"\a\n\n\n" <<"\t*******************************************************"<<endl <<"\t** **"<<endl <<"\t** Welcome To **"<<endl <<"\t** **"<<endl <<"\t** Student ARRAY and STRUCTURES Demo **"<<endl <<"\t** **"<<endl <<"\t*******************************************************"<<endl <<endl <<endl; cout<<"\t\t\t"; student_menu(); return 0; }//end main int student_menu() { system ("color 0F"); char student_menu_choice[5]; cout<<endl<<endl <<endl<<endl<<endl <<"\a\t *******************************************************"<<endl <<"\t ** **"<<endl <<"\t ** You Are In **"<<endl <<"\t ** **"<<endl <<"\t ** Student Menu **"<<endl <<"\t ** **"<<endl <<"\t *******************************************************"<<endl <<endl; loop_of_student_menu: cout<<"\t\t What do you want to do for student " <<endl <<"\t\t ===================================" <<endl <<endl << "\n\n\t 1 => Add student " << "\n\n\t 2 => Student menu Exit \n" << "\t=== ------------------ "<<endl <<"\t\t\t\tYou Select : "; cin >> student_menu_choice; i = atoi (student_menu_choice); if (i>0) { switch (i) { case 1: { add_student();//Function break ; } case 2: { return 0; }break ; default : { return 0; }break ; }//end switch }//end if else { system("CLS"); }//end else return 0; } void add_student() { system ("color F0"); system("CLS"); cout<<endl<<endl<<endl <<endl<<endl<<endl <<"\a\t *******************************************************"<<endl <<"\t ** **"<<endl <<"\t ** Adding Student **"<<endl <<"\t ** **"<<endl <<"\t *******************************************************"<<endl; cout<<endl <<"\t\tCOLLECTING DATA FOR EMPLOYEE NO : "<<size <<endl << "\n\tEnter name terminating at \".\" : "; cin.getline(stdInstance[size].name,20,'.');//taking name for(int i=0;i<6;i++){ cout<< "\n\tEnter Score For course # "<<i+1<<" : "; cin>>stdInstance[size].grade[i]; } cout<<endl <<"Student added with following data" <<endl <<endl <<"Name : "<<stdInstance[size].name <<endl; int sum=0, average=0; for(int j=0;j<6;j++){ cout<< "\n\tScore For course # "<<j+1<<" : "<<stdInstance[size].grade[j]; if(stdInstance[size].grade[j]<50){ cout<< "\n\tGrade is : F "; }else{ cout<< "\n\tGrade is : Not F "; } sum = sum + stdInstance[size].grade[j]; } cout<<"\n\n\tSum For courses : "<<sum; average=sum/6; cout<<"\n\n\tAverage For courses : "<<average ; if(average<50){ cout<< "\n\n\tNot Promoted "; }else{ cout<< "\n\n\tPromoted"; } size++; }
Write c++ program calculate 6 students subjects requirements total of 6 subjects, average, grade?
ReplyDeleteHere is the code of this program. Do follow it and give us your feedback about the program.
Deletehttp://www.pprogramming.com/2015/05/c-program-to-input-marks-of-6-subjects.html?showComment=1433233786979#c3795497328404608666
Write c++ program calculate 6 students subjects requirements total of 6 subjects, average, grade?
ReplyDeleteMazamed do you need to have code of this program ? Here is the code of this program
Deletehttp://www.pprogramming.com/2015/05/c-program-to-input-marks-of-6-subjects.html?showComment=1433233786979#c3795497328404608666
Thanks for offering your services Jimmy. Keep us visiting to get more latest articles about programming.
ReplyDelete