You are here:

C++/c++ Recursion !

Advertisement


Question
write a programe in c++ to find the factorial to any no
through iterative procedure or recursive procedure

Answer
Hi Dear Qaiser !

Thanks for your question !
Here im presenting you the simple version of C++ program to calculate factorial  of an integer using recursive procedure !
/*
  C++ Program to find factorial of a given number using recursion
*/


#include<iostream.h>

int fact(int n)
{
  if( n <= 0 )
     return 1;
  else
     return n* fact( n - 1);
}
void main()
{
  int no;
  cout<<"Enter a number :";
  cin>>no;
  cout<<"Fact "<<fact(no);
}

Thanks and Regards !
Prince M. Premnath
princeatapi@yahoo.co.in

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Prince M. Premnath

Expertise

Years of research in C/C++ Will bring you all facts regarding , OOPS , SVGA , MOUSE , BIOS , IVT , Feel free to query me :-)

Experience

More than 5 years

Education/Credentials
MCA

©2016 About.com. All rights reserved.