Answer to Question #255085 in C++ for Aashi

Question #255085
(1)Define a class student in C++ with the following description. a) data member roll number, name, score, and remarks b) member function to allow user (i) to enter the details (ii) to view the contents of all the data members.
1
Expert's answer
2021-10-22T04:53:51-0400

Source code



#include <iostream>
using namespace std;
class Student{
    private:
        int roll_number;
        string name;
        int score;
        string remarks;
    public:
        void getDetails(){
            cout<<"\nEnter roll number: ";
            cin>>roll_number;
            cout<<"\nEnter name: ";
            cin>>name;
            cout<<"\nEnter score: ";
            cin>>score;
            cout<<"\nEnter remarks: ";
            cin>>remarks;
        }
        void displayDetails(){
            cout<<"\nRoll number: "<<roll_number;
            cout<<"\nName: "<<name;
            cout<<"\nScore: "<<score;
            cout<<"\nRemarks: "<<remarks;
        }
};
int main()
{
    Student s;
    s.getDetails();
    s.displayDetails();


    return 0;
}


Output


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Riya
22.10.21, 11:30

Nice website

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS