PROGRAM TO FIND MEAN OF TWO NUMBERS USING FRIEND FUNCTION
/*WRITE A PROGRAM TO FIND MEAN OF TWO NUMBERS USING FRIEND FUNCTION*/
#include<conio.h>
#include<iostream.h>
class sample
{
int a;
int b;
public:
void set value()
{
a=25;
b=40;
}
friend float mean(samples);
};
float mean(samples)
{
return float(s.a+s.b)/2;
}
void main()
{
sample x;
x.setvalue();
cout<<"mean="<<mean(x);
}
----------------------------------------------------------
OUTPUT:-
#include<conio.h>
#include<iostream.h>
class sample
{
int a;
int b;
public:
void set value()
{
a=25;
b=40;
}
friend float mean(samples);
};
float mean(samples)
{
return float(s.a+s.b)/2;
}
void main()
{
sample x;
x.setvalue();
cout<<"mean="<<mean(x);
}
----------------------------------------------------------
OUTPUT:-
0 comments