//BCA Support
//www.bcasupport.xyz
#include <iostream.h>
#include <conio.h>
class c1
{
int no;
public:
c1()
{
no=10;
}
friend void average();
};
class c2
{
int no;
public:
c2()
{
no=20;
}
friend void average();
};
void average();
class c3
{
int no;
public:
c3()
{
no=30;
}
friend void average();
};
int main()
{
clrscr();
average();
getch();
return 0;
}
void average()
{
c1 obj1;
c2 obj2;
c3 obj3;
int avg;
cout<<"\nNumber 1 : "<<obj1.no;
cout<<"\nNumber 2 : "<<obj2.no;
cout<<"\nNumber 3 : "<<obj3.no;
avg=(obj1.no+obj2.no+obj3.no)/3;
cout<<"\nAverage = "<<avg;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.