Program
#include<iostream.h>
#include<conio.h>
//void fact(b);
class b
{
int n;
friend void
fact(b);
void print();
public:
b(int p)
{
n=p;
}
};
void b::print()
{
long f=1;
for(int
i=1;i<=n;i++)
f*=i;
cout<<"factorial
is==>"<<f;
}
void fact(b a)
{
a.print();
}
void main()
{
int n;
clrscr();
cout<<"enter
the number==>";
cin>>n;
b a(n);
fact(a);
getch();
}
Output:
enter the
number==>5
factorial
is==>120
0 comments:
Post a Comment