Find us On Facebook

Showing posts with label To find out the average of three no. Using friend function. Show all posts
Showing posts with label To find out the average of three no. Using friend function. Show all posts

Wednesday, April 6, 2011

W.A.P To find out the average of three no. Using friend function


#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

Programms

C,C++,VB, PL/SQL EBOOK SEARCH ENGINE