Follow Us

LightBlog

Breaking

Saturday, February 4, 2017

write a program to find the factorial of a number

 Write a  program to find  the  factorial of a number


    #include<stdio.h>
   #include<conio.h>
  int main()
{
  int i=1,fact=1,num;

  printf("Enter a number: ");
  scanf("%d",&num);

  while(i<=num)
{
      fact=fact*i;
      i++;
  }

  printf("Factorial of %d is: %d",num,fact);
  return 0;
}

Sample output:
Enter a number: 5
Factorial of 5 is: 120

No comments:

Post a Comment