Saturday, November 9
Factorial Using Recursive Function
#include <iostream>
#include <conio.h>
using namespace std;
int Factorial(int number)
{
if (number <2)
{
return 1;
}
else
{
return (number * Factorial(number - 1));
}
}
void main()
{
int num;
cout << "Enter Number: ";
cin >> num;
int fact = Factorial(num);
cout << "\nFactorial: " << fact;
_getch(); //use 'getch()' if you are using version older than Visual Studio 2013.
}












sir what is difference between getch and _getch ?
ReplyDeleteA very good blog it is
ReplyDeleteGood Blog But Sir It is Giving error in my IDE "Code Blocks " Which is
ReplyDeleteerror: stray '\240' in program twenty times ,,,,,
This means there was error in copying the code from here, try using double quotes of browser
ReplyDelete