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; }
1 Odpowiedź
0
it's working... i dont know why u asked