How to find volume of cylinder using friend function?
CODE
How to find volume of cylinder using friend function?
//Write a program to find volume
of cylinder using friend function…
#include<iostream>
using namespace
std;
class data
{
float r,h;
public:
void input()
{
cout<<"\n enter r and
h:";
cin>>r>>h;
}
friend void volume(data obj);
};
void
volume(data obj)
{
float v=obj.r*obj.h*3.14*obj.r;
cout<<"\n volume="<<v;
}
int main()
{
data obj;
obj.input();
volume(obj);
}
Output:
enter r and h:2
6
volume=75.36
How to find volume of cylinder using friend function?
Reviewed by Unknown
on
January 02, 2019
Rating:
No comments:
If you have any doubt or query ,comment below: