C Program to Find the Factorial of Entered Number

0
1
digitalample eye
Write a program to find factorial of entered number.
Write a program to display factorial of given number.
Write a c program to take input from user and find the factorial

C Code

#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{

int i, number, factorial =1;

printf("Enter number : ");
scanf("%d",&number);

if(number<0)
printf("error:negative number");

else if(number==0)
printf("factorial of 0 i 1");

else{
for (i=1; i<=number; i++)
factorial*=i;
printf("factorial is of %d is %d",number, factorial);
}

getch();
}

Output

find factorial
Always do experiment with c programming, here is another experiment with c programming code to find the factorial, 

C Code

#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{

int i, number, factorial =1;

printf("Enter number : ");
scanf("%d",&number);

for (i=1; i<=number; i++)
factorial*=i;
printf("factorial is of %d is %d",number, factorial);

getch();
}

Output

find factorial

LEAVE A REPLY

Please enter your comment!
Please enter your name here