Powered By Blogger

Friday, December 24, 2010

C Program to find the factorial of a number

/* C Program to find the factorial of a number accepted from the user */


#include <stdio.h>
int main()
{
    int i;
    int num;
    int fact=1;
    printf("Enter the number\n");
    scanf("%d",&num);
    for(i=num;i>=1;i--)
        fact=fact*i;
    printf("The factorial of the number is %d",fact);
    return 0;
}

No comments:

Post a Comment