Tuesday, 23 June 2015

C PROGRAM TO FIND FACTORIAL OF A NUMBER



#include <stdio.h>
int main()
{
    int i, count;
    unsigned long long int fc=1;        
    printf("Enter an integer value : ");
    scanf("%d",&i);
    if ( i< 0)
        printf("Error!!! Factorial of negative number doesn't exist.");
    else
    {
       for(count=1;count<=i;++count)  
       {
          fc*=count;            
       }
    printf("Factorial = %lu",fc);
    }
    return 0;
}

OUTPUT
Enter an integer value : 8
Factorial = 40320