TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Monday, 24 August 2020

Recursion In C++| Explain Recursion In C++| Program Of Recursion In C++| Syntax Of Recursion In C++| Recursion In C++ In Hindi

 

Recursion  In C++

The process in which a function calls itself is known as recursion and the corresponding function is called the recursive function.


image of Recursion  In C++

Fig: Recursion  In C++

Program:

#include<iostream.h>

int f(int n)

{

if(n<=1)

 return 1;

else

return n*f(n-1);

}

int main()

{

int num;

cout<<”enter a number”;

cin>>num;

cout<<”factorial of entered number:”<<f(num);

return 0;

}


Output:

Enter a number : 5

Factorial of entered number : 120

 

No comments:

Post a Comment