C++ program to calculate the factorial of a number using recursion.

Write a program to calculate the factorial of a number using recursion.

#include<iostream.h>
#include<conio.h>
void main()
{
	int n,fact;
	int rec(int); clrscr();
	cout<<"Enter the number:->";
	cin>>n;
	fact=rec(n);
	cout<<endl<<"Factorial Result are:: "<<fact<<endl;
	getch();
}
rec(int x)
{
	int f;
	if(x==1)
		return(x);
	else
	{
		f=x*rec(x-1);
		return(f);
	}
}

29 Responses to “C++ program to calculate the factorial of a number using recursion.”

  1. What i do not realize is actually how you are not really much more well-liked than you may be now. You are so intelligent. You realize therefore considerably relating to this subject, made me personally consider it from so many varied angles. Its like men and women aren’t fascinated unless it’s one thing to do with Lady gaga! Your own stuffs excellent. Always maintain it up!

    Reply
  2. program khoto che…pela program sudharo pachi upload karo
    halya avya …ama bija joine su sikhe .heee!

    Reply

Leave a Reply