Tuesday, October 4, 2011

Factorial

Program       :   Write a program to calculate factorial of given number
Created By  :   JABIR PATHAN 

#include<stdio.h>
#include<conio.h>
long int fact(int);
void main()
{
  int no;
  clrscr();
  printf("enter any number==>");
  scanf("%d",&no);
  printf("the factorial of entered number==>%d",fact(no));
  getch();
}



long int fact(int num)
 {
   if(num==1)
      return(1);
   else
      return(num*fact(num-1));
 }


No comments:

Post a Comment