factorial of number

18/07/2012 11:07

#include  <stdio.h>
#include  <conio.h>

void fact(int a)
{
    int i,res=1;
    for(i=1;i<=a;i++)
        res=i*res ;
    printf("\nThe factorial of the number is:%d",res);
}


int main()
{
    int num;
    clrscr();

    printf("\nThis tool will find out the factorial of a number");
    printf("\nPls enter a number:");
    scanf("%d",&num);

    fact(num);
    getch();
    return 0;
}