Write a recursive function Factorial. The function takes a number and returns the factorial of that number if its more than 0, or else return 1. Main will call this function up to 10 times to Show up to 10 !
The sample output as below.
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
10! = 3628800
You should really read the tutorial on this site, it will help you a lot. But just a basic explanation or two:
a for loop is generally used to iterate over something, but it has other uses as well. here it is used to call the fact function with different values and print the results.
the line: cout<<i<<"! ="<<fact(i);
cout is the standard output stream and the "<<" are used instead of: cout(//stuff to output, more stuff, even more stuff)
but like i said read the tutorial: http://www.cplusplus.com/doc/tutorial/