#include<iostream.h>
#include<conio.h>
long int factorial(int n){
lng int f=1;
for(int i=1;i<=n;i++) f=f*i;
return f;
}
int main(){
long int fact;
int num;
clrscr();
cout<<"Enter a Positive Integer Number"<<endl;
cin>>num;
if(num>0){
fact=factorial(num);
cout<<"Factorial of "<<num<<" = "<<fact<<endl;
}
else{
cout<<"Wrong Number Inserted"<<endl;
}
getch();
return 1;
#include<conio.h>
long int factorial(int n){
lng int f=1;
for(int i=1;i<=n;i++) f=f*i;
return f;
}
int main(){
long int fact;
int num;
clrscr();
cout<<"Enter a Positive Integer Number"<<endl;
cin>>num;
if(num>0){
fact=factorial(num);
cout<<"Factorial of "<<num<<" = "<<fact<<endl;
}
else{
cout<<"Wrong Number Inserted"<<endl;
}
getch();
return 1;
}
No comments:
Post a Comment