Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sricharan200 authored Nov 28, 2023
1 parent c059bc1 commit f97b8ff
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions C/factorial.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <stdio.h>

int main() {
int num;
unsigned long long fact = 1;

printf("Enter a non-negative integer: ");
scanf("%d", &num);

if (num < 0) {
printf("Factorial is not defined for negative numbers.\n");
} else {
for (int i = 1; i <= num; i++) {
fact *= i;
}
printf("Factorial of %d = %llu\n", num, fact);
}

return 0;
}

0 comments on commit f97b8ff

Please sign in to comment.