Answer to Question #255159 in C++ for Aashi

Question #255159
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-22T06:36:40-0400
#include<iostream>
using namespace std;
class student{
	private:
		int roll_number;
		string name;
		double  score;
		string remarks;
	public:
	void input(){
		cout<<"Enter student roll number: \n";
		cin>>roll_number;
		cout<<"Enter the student name:\n";
		cin>>name;
		cout<<"Enter student score:\n";
		cin>>score;
		cout<<"Enter student remarks:\n";
		cin>>remarks;
	} 
	void view(){
		cout<<"Roll number:  "<<roll_number<<endl;
		cout<<"Name:  "<<name<<endl;
		cout<<"Score:  "<<score<<endl;
		cout<<"Remark:  "<<remarks<<endl;
		
	}
};


int main(){
	student st;
	st.input();
	st.view();
}

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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS