Create a program that asks the user to input the full name and a number (1-10). Create two functions
One function that receives that number and print the factorial of value of that number.
Second function that print the table of that number ranges from -5 till +10, and count the negative and positive values of the multiplied number answers.
#include<iostream>
using namespace std;
int factorial(int n);
int main()
{
int n;
cout << "Enter a positive integer: ";
cin >> n;
cout << "Factorial of " << n << " = " << factorial(n);
return 0;
}
int factorial(int n)
{
if(n > 1)
return n * factorial(n - 1);
else
return 1;
}
Comments
Leave a comment