Friday, 15 May 2015

Program To Print Factorial In C

Print Factorial in C

Problem Statement: Write a program in c that will print the factorial of a given number using for loop.

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

int main()
{
int fact,num,i;
fact=1;
printf("enter the number of factorial: ");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
   fact=fact*i;
}
printf("\n%d",fact);
getch();
} 
                                                                                 

0 comments:

Post a Comment