pc008.c (671B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* Factorial upto N */ 8 9 #include <stdio.h> 10 11 int main() 12 { 13 int n, i; 14 long long fact = 1; 15 printf("Enter n : "); 16 if (scanf("%d", &n) != 1) 17 { 18 printf("\nOnly non-negative number allowed."); 19 return 1; 20 } 21 if (n < 0) 22 { 23 printf("\nOnly non-negative number allowed."); 24 return 1; 25 } 26 if (n == 0) 27 { 28 printf("\nFactorial of 0 : 1"); 29 return 0; 30 } 31 for (i = 1; i <= n; i++) 32 fact *= i; 33 printf("\nFactorial of %d : %lld", n, fact); 34 return 0; 35 }