Thursday 23 January 2014

c program for factorial

Q how to find factorial in  c program |c programming examples

Ans: here is code that get input from user and print the n factorial 
#include<stdio.h>
int main()
{

int c,n,fact=1;
c programming examplesprintf("enter a number calculate its factorial\n");
scanf("%d",&n);
for(c=1;c<=n;c++)
    fact=fact*c;
printf("factorial of %d=%d\n",n,fact);
return 0;
}

No comments:

Post a Comment