Jai and Bala once went to a college. The students of that college where doing a software in which when you enter an id number and student name it should display the entered details. Both are studying c++ so they wanted to solve this problem using class and object.
Answers
Explanation:
Dhaustoodyoulckzutzodixnsistix
The below given program will display the entered details of the students:
#include<iostream>
using namespace std;
class student
{
private:
char name[20],regd[10],branch[10];
int sem;
public:
void input();
void display();
};
void student::input()
{
cout<<"Enter Name:";
cin>>name;
cout<<"Enter Regdno.:";
cin>>regd;
cout<<"Enter Branch:";
cin>>branch;
cout<<"Enter Sem:";
cin>>sem;
}
void student::display()
{
cout<<"\nName:"<<name;
cout<<"\nRegdno.:"<<regd;
cout<<"\nBranch:"<<branch;
cout<<"\nSem:"<<sem;
}
int main()
{
student s;
s.input();
s.display();
}
The output will be :
Enter Name:
Enter Regdno.:
Enter Branch:
Enter Sem:
#SPJ3