Sunday 20 October 2013

Factorial in C

#include <stdio.h>
#include<conio.h>
void main()
{
int x,fact;
printf("enter the number:");
scanf("%d",&x);
if(x==0)
{
fact=1;
printf("%d",fact);
}
  else
  {
      while(x!=0)
        {
     fact=x * (x-1);
      x--;
    }
printf("%d",fact);
  }
}

No comments :

Post a Comment