+ 2
Create a class "student" with roll ,name 9th marks and 10 th marks and find the total marks of each of the above courses individ
6 Answers
+ 5
đ
+ 4
#include <iostream>
using namespace std;
//Compiler version g++ 6.3.0
class student {
public:
int roll;
char name[10];
float sub1, sub2, sub3, sub4, sub5, sub6, sub7;
void get()
{
cout<<"\nEnter 9th marks "<<endl;
cin>>sub1>>sub2>>sub3;
cout<<"\nEnter 10th marks "<<endl;
cin>>sub4>>sub5>>sub6>>sub7;
}
float total(float sub1, float sub2, float sub3)
{
return sub1+sub2+sub3;
}
float total(float sub1, float sub2, float sub3, float sub4)
{
return sub1+sub2+sub3+sub4;
}
};
int main()
{
student s;
s.get();
cout<<"\nTotal 9th marks :"<<
s.total(s.sub1,s.sub2,s.sub3);
cout<<"\nTotal 10th marks :"<<
s.total(s.sub4,s.sub5,s.sub6,s.sub7);
}
+ 2
C++
+ 2
Sapna Rani your code is running perfectly, then what is it that you want help with?
+ 2
If you want it to look more professional then just keep the member functions public and rest private in class.
+ 1
Your attempt?