0

Write a cpp program to calculate factorial using inline function.

#include <iostream> // Declare inline function to calculate factorial inline int factorial(int n) { int result = 1; for (int i = 1; i <= n; i++) { result *= i; } return result; } int main() { std::cout << "Enter a number to calculate its factorial: "; int n; std::cin >> n; // Call inline function to calculate factorial int result = factorial(n); std::cout << "The factorial of " << n << " is " << result << std::endl; return 0; }

3rd Jan 2023, 12:14 AM
Jainam Mochi
Jainam Mochi - avatar
1 Réponse
0
it's working... i dont know why u asked
3rd Jan 2023, 6:34 PM
Khabibullokh
Khabibullokh - avatar