C++ programming-Factorial of given number

C++ programming-Factorial of given number

6 10 99
C++ programming-Factorial of given number 10 6 99


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n;
long int fact(int n);
cout<<"enter a number\n";
cin>>n;
cout<<"factorial="<<fact(n)<<endl;
getch();
}
long int fact(int n)
{
if(n==0)
return 1;
else
 return(n*fact(n-1));
 }


output
enter a number
6
factorial=720

0 comments:

Post a Comment

 
HowTo © 2015 | HowTo | Design By HowZto | HOWTO
Top