Saturday, September 27, 2014

Create a class containing name and age of the employee as data member and getdata and putdata member function for getting and displaying the output. Using array of objects declare the number of employee object and list out their name and age.

ALGORITHM:
1.      Declare class record
2.      getdata()
i.      enter name
ii.     enter age
3.      showdata()
i.                    display name and age
4.      main()
for(i=0;i<3 i="" o:p="">
            s[i].setdata()
             for(i=0;i<3 i="" o:p="">
            s[i].showdata()
5.      end

CODE:

#include
#include
class employee
{
            private:
            char name[25];
            int age;
            int n;
            public:

                        void getdata(void)
                        {
                                    cout<
                                    cin>>name;
                                    cout<
                                    cin>>age;
                        }
                        void showdata()
                        {
                                    cout<<"Name:"<
                                    cout<<"Age:"<
                        }

};
void main()
{
            clrscr();
            employee e[100];
            int n=0;
            cout <<"How many Employees???"<
            cin>>n;
            for (int i=0 ;i
            e[i].getdata();
            for (i=0;i
            e[i].showdata();
            cout<<"Total no. of employees:"<
            getch();
}


No comments:

Post a Comment