Create a structure student with roll,name,10th marks, +2marks and graduation marks,and find the total marks of each of the above courses individually by using function overloading.
#include <iostream>
using namespace std;
//roll,name,10th marks, +2marks and graduation marks
struct Student
{
string roll;
string name;
int marks_10th;
int marks_2pls;
int graduation_marks;
};
void totalMarks(Student m1){
int n;
cout<<"Enter number of subjects: ";
cin>>n;
for (int i=0;i<n;i++){
cout<<"Enter marks for subject "<<i+1<<":";
cin>>m1.marks_10th;
}
}
void totalMarks(Student m2,int n){
cout<<"Enter number of subjects: ";
cin>>n;
for (int i=0;i<n;i++){
cout<<"Enter marks for subject "<<i+1<<":";
cin>>m2.marks_2pls;
}
}
void totalMarks(){
Student m3;
int n;
cout<<"Enter number of subjects: ";
cin>>n;
for (int i=0;i<n;i++){
cout<<"Enter marks for subject "<<i+1<<":";
cin>>m3.graduation_marks;
}
}
int main()
{
return 0;
}
Comments
Leave a comment