PERSONAL DETAILS

Muthumari_B · updated September 08, 2021 · C++
// Read and display the personal details using class and objects 


#include<iostream>
using namespace std;
class personal_details
{
        char name[20], blood[10], gender[10], nationality[10],
        father[30], mother[30], place[20];
        int date, month, year, age;
        public:
                void getdata();
                void display();
};

void personal_details::getdata()
{
        cout<<"\n Enter Name : ";
        cin>>name; 
        cout<<name<<endl;
        cout<<"\n Enter Date of Birth : ";
        cin>>date>>month>>year;
        cout<<date<<"."<<month<<"."<<year<<endl;
        cout<<"\n Enter Age : ";
        cin>>age;
        cout<<age<<endl;
        cout<<"\n Enter Blood Group : ";
        cin>>blood;
        cout<<blood<<endl;
        cout<<"\n Enter Gender : ";
        cin>>gender;
        cout<<gender<<endl;
        cout<<"\n Enter Nationality : ";
        cin>>nationality;
        cout<<nationality<<endl;
        cout<<"\n Enter Father's Name : ";
        cin>>father;
        cout<<father<<endl;
        cout<<"\n Enter Mother's Name : ";
        cin>>mother;
        cout<<mother<<endl;
        cout<<"\n Enter Place : ";
        cin>>place; 
        cout<<place<<endl;
}
void personal_details::display()
{
       cout<<"\n ____ Personal Details ____"<<endl;
       cout<<"\n Name  : "<<name<<endl;
       cout<<"\n Date of Birth  : "<<date<<"."<<month<<"."<<year<<endl;
       cout<<"\n Age  : "<<age<<endl;
       cout<<"\n Blood group : "<<blood<<endl;
       cout<<"\n Gender  : "<<gender<<endl;
       cout<<"\n Nationality  : "<<nationality<<endl;
       cout<<"\n Father's Name  : "<<father<<endl;
       cout<<"\n Mother's Name  : "<<mother<<endl;
       cout<<"\n Place  : "<<place<<endl;
}
int main()
{
       personal_details d;
        d.getdata();
        d.display();
}

Comments

Please sign up or log in to contribute to the discussion.