C Program to Calculate Factorial of a Number Using Function फंक्शन का उपयोग करके किसी संख्या का Factorial ज्ञात करने का C प्रोग्राम
In C language, a user-defined function can be used to calculate the factorial of a number. The factorial of a non-negative integer is the product of all positive integers from 1 to that number. C भाषा में User-Defined Function का उपयोग करके किसी संख्या का Factorial ज्ञात किया जा सकता है। किसी non-negative integer का factorial, 1 से उस संख्या तक की सभी धनात्मक पूर्ण संख्याओं का गुणनफल होता है। Formula (सूत्र) n! = n * (n-1) ...*3*2*1 Example: 5! = 5 * 4 * 3 * 2 * 1 = 120 Also, (0! = 1). C Program #include <stdio.h> unsigned long long factorial(int x); int main(void) { int n; unsigned long long ans; printf("Enter an integer number: "); scanf("%d", &n); if (n >= 0 && n <= 20) { ans = factorial(n); printf("Factorial of %d = %llu\n", n, ans); } else { printf("Invalid input! Enter a number from 0 to 20.\n"); } return 0; } unsigned long long factorial(int x) { ...