Power By Dholu Production

Responsive Ads Here

Tuesday, April 24, 2018

Write a prg to find the mean value of given number using friends functio|C++


#include<iostream>
using namespace std;

class sample
{
    float x,y;
    public:
    float get()
    {
        cout<<"Enter x="<<endl;
        cin>>x;
        cout<<"Enter y="<<endl;
        cin>>y;
    }
    friend float mean (sampleA);
};

float mean(sampleA)
{
    return((A.x+A.y)/2.0);
}

int main()
{
    sample s;
    s.get();
    cout<<"ANS="<<mean(s);
    return 0;
}