Programming

C Program to Find the Factorial of Entered 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

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.