answersLogoWhite

0

#include
#include

using std::cin;
using std::cout;
using std::endl;
using std::tolower;

long factorial(int N);

int main()
{
int N = 0; //factorial of N
char command = 'n';
do
{
cout << "Enter a number to calculate factorial: ";
cin >> N;

cout << endl << "Factorial of " << N << " is: " << factorial(N) << endl;

cout << "Do you want to continue (y/n)?";
cin >> command;
cout << endl;
} while ('y' == tolower(command));

system("PAUSE");
return 0;
}

long factorial(int N)
{
if (N == 0)
{
return 1;
}
else
{
return (N * factorial(N - 1));
}
}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Write a c program to accept a numbers and generate square root cube and exponential values?

write a c program to accept a number and generate a square root cube and exponential values


How do you write program c of table 5?

#include#includevoid main(){ int a,i;printf("\nThe Multiplication table of 5 is:\n");for(i=1;i


How do you generate a parse tree from an expression using C program?

c code for top down parser


How do you write a binomial distribution table in C program?

Class&amp;genus


C program to generate numbers from 1 to 100 divisible by 2?

(rand()&amp;50+1)*2


Program to generate Fibonacci series using storage class in c plus plus?

i dn't know. haha


Write a c program to generate student mark details using union and find total and average and grade?

write a c program to display marks,total,average,grade using union


What is Peterson number in C?

Peterson Number:145 = 1! + 4! + 5!number=sum of (factorials of digits)


Dry run table in flow-chart?

/* my second program in C++ with more comments */ #include &lt;iostream&gt; using namespace std; int main () { cout &lt;&lt; "Hello World! "; // prints Hello World! cout &lt;&lt; "I'm a C++ program"; // prints I'm a C++ program return 0; }


How do you program C programming language in a device?

You need to get an SDK for the device you are planning to program for, SDK also lets you run your program on PC in an emulator. Once written you can then compile the program for device which would generate an installer package that you can then install on the device.


Is there a c program to generate the series a a b a b c?

You need to be more specific in what you are asking. For example, the following meets your requirements: int main() { printf("a a b a b c\n"); return 0; }


Which program produces the obj file assembly or C plus plus?

A compiler produces object code, which is an obj file.