#include<stdio.h>
#include<conio.h>
long factorial(long f){
if(f==1) return 1;
return f*factorial(f-1);
}
void main(){
long fact=1,n;
clrscr();
printf("Enter a Positive Integer Value\n");
scanf("%ld",&n);
if(n>0){
fact=factorial(n);
printf("Factorial of %ld = %ld\n",n,fact);
}
else{
printf("Wrong Value Inserted\nPlease Try Again!!\n");
}
getch();
}
#include<conio.h>
long factorial(long f){
if(f==1) return 1;
return f*factorial(f-1);
}
void main(){
long fact=1,n;
clrscr();
printf("Enter a Positive Integer Value\n");
scanf("%ld",&n);
if(n>0){
fact=factorial(n);
printf("Factorial of %ld = %ld\n",n,fact);
}
else{
printf("Wrong Value Inserted\nPlease Try Again!!\n");
}
getch();
}
No comments:
Post a Comment