Popular Posts

4.Write a program to enter name and age of a person and show name and age.

4.Write a program to enter name and age of a person and show name and age.

#include
#include
class person
{
char name[20];
int age;
public:
void getdata(void);
void display(void);
};
void person::getdata(void)
{
cout<<"Enter name: "; cin>>name;
cout<<"Enter age: "; cin>>age;
}
void person::display(void)
{
cout<<"\n Name: "< cout<<"\n Age: "< }
int main()
{
clrscr();
person p;
p.getdata();
p.display();
getch();
return 0;
}

Output:

Enter name: vivasolve.blogspot.com
Enter age: 21

Name: vivasolve.blogspot.com
Age: 21

No comments: