Sunday, July 31, 2016

Program in C to find the factorial of a given number


/* Program to find the factorial of a given number */
#include<stdio.h>
#include<conio.h>
void main()
{
    int i, num, fact = 1;

  printf("\n Enter a number to calculate it's factorial : ");
  scanf("%d", &num);

  for (i = 1; i <= num; i++)
    fact = fact * i;

  printf(" Factorial of %d = %d\n", num, fact);
  getch();
}

0 comments:

Post a Comment