Menu

Wednesday, 2 March 2016

Factorial Program in C

#include <stdio.h>
#include<conio.h>
void main()
{
  int numbr, fac = 1, k ;

  printf("Enter a number \n");
  scanf("%d", &numbr);

  for (k = 1; k <= numbr; k++)
{  
   fac = fac * k;
}
  printf("Factorial of %d is  %d\n", numbr, fac);

  getch();
}

No comments:

Post a Comment