Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save scratchyourbrain/84c19325dba1ca64f490 to your computer and use it in GitHub Desktop.
Save scratchyourbrain/84c19325dba1ca64f490 to your computer and use it in GitHub Desktop.
C Program to Find Factorial of a Number
#include <stdio.h>
int main()
{
int n, count;
int factorial=1;
printf("Enter an integer: ");
scanf("%d",&n);
if ( n< 0)
printf("Error!!! Factorial of negative number doesn't exist.");
else
{
for(count=1;count<=n;++count)
{
factorial*=count;
}
printf("Factorial = %d",factorial);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment