C++ program to display student details using class
Write a C++ code to display student information using class and object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
#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
————-