#include<iostream.h>
#include<conio.h>
class Sample {
int a,b,c;
public:
void getdata() {
cout<<"\nEnter 3 no's";
cin>>a>>b>>c;
}
friend float average(Sample obj);
};
float average(Sample obj) {
float avg;
avg=(obj.a+obj.b+obj.c)/3.0;
return(avg);
}
void main() {
clrscr();
Sample obj;
obj.getdata();
float avg=average(obj);
cout<<"\n\n\t\t Average = "<<avg;
getch();
}
OUTPUT:-
Enter 3 no's 90
80
70
Average = 80
0 comments:
Post a Comment