jituTechnology

jituTechnology

>2.4 Design a class called Person that contains appropriate members for storing name, age, gender and telephone number

>

/*Design a class called Person that contains appropriate members for storing name, age, gender and telephone number. Write member functions that can read and display these data.

Programmed by:
Name: Jitendra Kr Yadav
Roll: 10116(NCIT-ELX)
Date:20 july,2011*/
                                                                                                         
#include<iostream.h>
#include<conio.h>
#include<math.h>
class Person
{
private:
char name[30];
int age;
char gender[7];
char phno[11];
public:
void assign(char a[],int y,char c[],char d[]);
void show();
};
void Person::assign(char x[],int y,char c[],char w[])
{
strcpy(name,x);
age=y;
strcpy(gender,c);
strcpy(phno,w);
}
void Person::show()
{
cout<<“name:”<<name<<endl<<“age:”<<age<<endl<<“gender:”<<gender<<endl<<“tel:”<<phno<<endl;
}
int main()
{
Person d[2];
char n[30],g[7],p[11];int a;
for(int i=0;i<2;i++)
{
cout<<“Enter name ,gender, phono and age”<<endl;
cin>>n>>g>>p>>a;
d[i].assign(n,a,g,p);
}
for(int i=0;i<2;i++)
{
d[i].show();
}
getch();
return(0);
}
Output Sample:
Enter name, gender, phone and age
Jitendra
Male
9849151519
20
Enter name, gender, phone and age
Erick
Female
01236849975
19
Name: Jitendra
Age: 20
Gender: Male
Tel: 9849151519
Name: Erick
Age: 19
Gender: Female
Tel: 01236849975
Add a comment

Comments (1)

  1. BellaSeptember 2, 2012 Reply
    The gneuis store called, they’re running out of you.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

October 2019
S M T W T F S
« Jun    
 12345
6789101112
13141516171819
20212223242526
2728293031