+ 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

13th Jul 2020, 6:02 AM
Sapna Rani
Sapna Rani - avatar
6 ответов
+ 5
👍
13th Jul 2020, 6:23 AM
Sapna Rani
Sapna Rani - avatar
+ 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); }
13th Jul 2020, 6:13 AM
Sapna Rani
Sapna Rani - avatar
+ 2
C++
13th Jul 2020, 6:04 AM
Sapna Rani
Sapna Rani - avatar
+ 2
Sapna Rani your code is running perfectly, then what is it that you want help with?
13th Jul 2020, 6:17 AM
Arsenic
Arsenic - avatar
+ 2
If you want it to look more professional then just keep the member functions public and rest private in class.
13th Jul 2020, 6:18 AM
Arsenic
Arsenic - avatar
+ 1
Your attempt?
13th Jul 2020, 6:03 AM
Arsenic
Arsenic - avatar