Tuesday, April 7, 2015

43. Write a program to find out factorial of any number.


#include<stdio.h>
#include<conio.h>
void main()
{  
int i,n;
long int fact=1;
clrscr();      
printf("\n Input any number:- ");
scanf("%d", &n);
if(n<0)
printf("\n Invalid Number");  
e1se if(n==0 ll n==1)    
printf("\n Factorial of %d is l",n);
  else   
 { 

   for(i=1; i<=n;i++)  
fact= fact*i;  
printf("\n Factorial of %2d = %1d", n, fact);
}

getch();
}

1 comment: