Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

C program of factorial of a number



In this C-program we will calculate the factorial of a number. The number will be taken from the user.color>

input:

The number(i.e : 5,6,9 etc.)

output:

The factorial of the given number

CODE---->


#include
#include
color> void main()color>
{
int i,n,fact=1;
clrscr();
printf("Enter a number:-color>");
scanf("%dcolor>",&n);
if(ncolor>)
{
printf("\n%d is a negative number. Factorial of a negative number doesn't exist.color>",n);
}
if(n==0color>)
{
printf("\nThe factorial of 0 is = 0color>");
}
if(n>0color>)
{
for(i=1color>;i;i++color>)
{
fact=fact*i;
}
printf("\nThe factorial of %d is = %dcolor>",n,fact);
}

getch();
}
Notecolor>:The program of multiplication of integers upto range 'n' is also the same program of above.color>




Don't just read, write it, run it.....color>




This post first appeared on ProgramJoy.blogspot.com, please read the originial post: here

Share the post

C program of factorial of a number

×

Subscribe to Programjoy.blogspot.com

Get updates delivered right to your inbox!

Thank you for your subscription

×