CodeClerks

C Program to Find Factorial of a Number



Write the reason you're deleting this FAQ

C Program to Find Factorial of a Number

Today I have just write a simple program to find factorial of a number. I have done this for college. I have wrote and run the code with CodeBlocks But when I was trying to run the code with trubo it was giving wrong result for large number !! I don't know why ?? anybody can help me with this please ??

My code...
#include <stdio.h>
int main ()
{
int number,i,factorial;
factorial = 1;
printf("Please enter an integer : ");
scanf("%d", &number);
if (number < 0)
{
printf("Factorial of negative value does not exist !!");
}
else
{
for (i = 1; i <= number; i++)
{
factorial = factorial * i;
}
printf("Factorial of %d is %d", number,factorial);
}
return 0;
}

Comments

Please login or sign up to leave a comment

Join