Created
December 17, 2014 08:56
-
-
Save scratchyourbrain/84c19325dba1ca64f490 to your computer and use it in GitHub Desktop.
C Program to Find Factorial of a Number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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