C++ Programming Code Examples
C++ > Recursion Code Examples
Program takes a Positive integer & Calculates the factorial of the number. First user enter 6 then, Factorial will be equal to '1*2*3*4*5*6' 720. Learn to Find the "Factorial" of a number
This technique can only calculate power if the exponent is a 'positive integer'. To find power of a number, you can use pow() function. C++ program calculates the power of any number
User enters a number which stores in variable "num". Then number "passes as argument" in function call A static variable is used to check that how many times function is called. When
In mathematics, the 'Euclidean' algorithm, or Euclid's algorithm, is a method for computing the 'greatest common divisor' of two (usually positive) integers, also known as the greatest
The "positive numbers" 1, 2, 3... are known as natural numbers. The program below takes a 'positive integer' from the user and calculates the sum up to the given number. You can find
This C++ program takes a sentence from user and "Reverses" that sentence using recursion. This sample doesn't 'use string' to reverse the sentence or store the sentence. User is asked
Direct Recursion: When function calls itself, it is called "Direct recursion". Indirect recursion: When function calls "another function" & that function calls the calling function, then this is