/*Create a class student with private data members name ,roll no,age and member functions input() to take input of data and display() to display the records .
Test the program for one student*/
#include<iostream.h>
#include<string.h>
#include<conio.h>
class student
{
private:
char name[25];
int roll,age;
public:
void input(char nam[] ,int rol,int ag);
void display(void);
};
void student::input(char nam[25],int rol,int ag)
{
strcpy(name,nam);
roll=rol;
age=ag;
}
void student::display()
{
cout<<"Name : "<<name<<endl;
cout<<"Roll No : "<<roll<<endl;
cout<<"Age : "<<age<<endl;
}
int main()
{
student st;
char name[25];
int roll,age;
cout<<"\nEnter Name : "<<endl;
cin>>name;
cout<<"Enter Roll No: "<<endl;
cin>>roll;
cout<<"Enter Age : "<<endl;
cin>>age;
st.input(name,roll,age);
st.display();
getch();
return 0;
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment