Get Update on recent Technology & Programming

Wednesday, 15 November 2017

C Program to find the factorial of any number

Posted by   on Pinterest

C Program to find the factorial of any number






#include<stdio.h>

int main(void)

{

 int n,num;

 long fact=1;

 printf("Enter a number : ");

 scanf("%d",&n);

 num=n;

 if(n<0)

  printf("No factorial of negative number\n");

 else

 {

  while(n>1)

  {

   fact*=n;

   n--;

  }

  printf("Factorial of %d=%ld\n",num,fact);

 }

 return 0;

}




No comments:
Write comments

Hey, we've just launched a new custom color Blogger template. You'll like it -
Join Our Newsletter