Code:
#include <iostream> // Note, its not iostream.h
include namespace std; // When changing iostream.h to iostream include this, otherwise you will get errors.
// Function prototype:
void factorial();
//Generate factorial numbers
int yournum;
int final;
int working;
int main()
{
cin>>yournum;
final=yournum;
working=yournum-1;
if(yournum<=0)
{
cout<<"Error sorry";
}
else
{
factorial();
}
cout<<"\nPress any key to exit";
cin.get();
return 0;
}
void factorial()
{
if(working<=0)
{
cout<<"Your number was !", yournum, " which equals ", final;
return;
}
working=working-1;
working*final=final;
factorial();
}