Saturday, September 27, 2014

Create a class containing name, age, weight as data members and setdata(),showdata() as member function to get and display the details. Write a main program to test the program.

ALGORITHM:
1.      Delcare class info with data members name,age and weight and member functions setdata() and showdata()
2.      setdata()
i.                    enter name
ii.                  enter age
iii.                enter weight
3.      showdata()
i.                    display name, age and weight
CODE
#include
#include
class grp
{
            char name[20];
            int age;
            int weight;
            public:
            void setdata(void)
            {
                        cout<
                        cin>>name;
                        cout<
                        cin>>age;
                        cout<
                        cin>>weight;
            }
            void showdata()
            {
                        cout<

                        cout<

                        cout<

            }
};
            void main()
            {
                        clrscr();
                        grp s1;
                        s1.setdata();
                        s1.showdata();

                        getch();


            }

No comments:

Post a Comment