Monday, June 18, 2012

To find the factorial of a number


/* To find the factorial of a number */

#include<stdio.h>

#include<conio.h>

void main()

{

  int n,i;

  long int fact=1;

  clrscr();

  printf("\nEnter the number: ");

  scanf("%d",&n);

  i=1;

  while(i<=n)

  {

    fact=fact*i;

    i=i+1;

  }

  printf("\nFactorial value=%ld",fact);

  getch();

}

 

 

OUTPUT

 

Enter the number: 12

 

Factorial value=479001600

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.