Factorial of a number

Program Description

In this code factorial of given number is found.
For eg. Given number is 5 then output will be 120.

Program
/***********************************
*   Factorial of a number
*	
*	code.cheraus.com
*
***********************************/
#include<stdio.h>
#include<conio.h>

void main()
{
  int num,i,f=1;
  clrscr();
  printf("\nEnter the number : ");
  scanf("%d",&num);
  
  for(i=1;i<=num;i++);
   f = f * i;
   
   printf("Factorial of number %d is : %d",num,f);
   getch();
}

Output
Test Case 1:

Enter the number : 5
Factorial of number 5 is : 120
Test Case 2:

Enter the number : 0
Factorial of number 0 is : 1

Comments
comments powered by Disqus