Write a C++ code to display student information using class and object.
#include<iostream> using namespace std; class Student_Details { private: char name[20],RollNo[10],Section[10]; int Semester; public: void input(); void show(); }; void Student_Details::input() { cout<<"Enter Name:"; cin>>name; cout<<"Enter RollNono.:"; cin>>RollNo; cout<<"Enter Section:"; cin>>Section; cout<<"Enter Semester:"; cin>>Semester; } void Student_Details::show() { cout<<"\nName:"<<name; cout<<"\nRollNono.:"<<RollNo; cout<<"\nSection:"<<Section; cout<<"\nSemester:"<<Semester; } int main() { Student_Details s; s.input(); s.show(); }
Output
Enter Name:Shamil
Enter RollNono.:7
Enter Section:A
Enter Semester:3
Name:Shamil
RollNono.:7
Section:A
Semester:3
————-