Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Homework HelpRSS Feeds

Program of nesting member functions, private member functions and array of objects

Posted By: Alyssa Campbell     Category: C++ Programming     Views: 8155

Write a program of nesting member functions,private member functions and array of objects.

Code for Program of nesting member functions, private member functions and array of objects in C++ Programming

#include<iostream.h>
#include<conio.h>
class data
{
    int rollno,maths,science;
    int avg();
    public:
        void getdata();
        void putdata();
};

main()
{
    clrscr();
    data stud[5];
    for(int i=0;i<5;i++)
        stud[i].getdata();
}

void data::getdata()
{
    cout<<"Please enter rollno:";
    cin>>rollno;
    cout<<"Please enter maths marks:";
    cin>>maths;
    cout<<"Please enter science marks:";
    cin>>science;
    putdata();
}

int data::avg()
{
    int a;
    a=(maths+science)/2;
    return a;
}

void data::putdata()
{
    cout<<"Average is :"<<avg()<<endl;
}
  
Share: 



Alyssa Campbell
Alyssa Campbell author of Program of nesting member functions, private member functions and array of objects is from Toronto, Canada.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!