How to find volume of cylinder using friend class ?

CODE




How to find volume of cylinder using friend class ?

//Write a program to find volume of cylinder using friend class…

include<iostream>
using namespace std;
class data
{
    float r,h;
public:
    void input()
    {
        cout<<"\n enter r and h:";
        cin>>r>>h;
    }
    friend class pro;
};
class pro
{
    public:
    void volume(data obj)
    {
        float v=obj.r*obj.h*3.14*obj.r;
        cout<<"\n volume="<<v;
    }
};
int main()
{
    data obj;
    obj.input();
    pro p;
    p.volume(obj);
}


Output:
enter r and h:5
7

 volume=549.5

How to find volume of cylinder using friend class ? How to find volume of cylinder using friend class ? Reviewed by Unknown on January 02, 2019 Rating: 5

No comments:

If you have any doubt or query ,comment below:

Programming copyright © 2018-19. Powered by Blogger.