#include<iostream.h>
#include<conio.h>
int fact(int);
void main()
{
clrscr();
int n,f;
cout<<"Enter a number : ";
cin>>n;
f=fact(n);
cout<<"Factorial of the given number is : "<<f;
getch();
}
int fact(int n)
{
int x;
if(n==1)
x=1;
else
x=n*fact(n-1);
return(x);
}
#include<conio.h>
int fact(int);
void main()
{
clrscr();
int n,f;
cout<<"Enter a number : ";
cin>>n;
f=fact(n);
cout<<"Factorial of the given number is : "<<f;
getch();
}
int fact(int n)
{
int x;
if(n==1)
x=1;
else
x=n*fact(n-1);
return(x);
}
No comments:
Post a Comment