Skip to content

Commit

Permalink
Merge pull request seeditsolution#255 from Ankit-07-17/patch-1
Browse files Browse the repository at this point in the history
Factorial_of_a_number
  • Loading branch information
seeditsolution authored Oct 2, 2020
2 parents 012a9e4 + 619414d commit 4ae8c0f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Factorial_of_a_number
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>
int main() {
int n, i;
unsigned long long fact = 1;
printf("Enter an integer: ");
scanf("%d", &n);

// shows error if the user enters a negative integer
if (n < 0)
printf("Error! Factorial of a negative number doesn't exist.");
else {
for (i = 1; i <= n; ++i) {
fact *= i;
}
printf("Factorial of %d = %llu", n, fact);
}

return 0;
}

0 comments on commit 4ae8c0f

Please sign in to comment.