Tag Archives: Recursion

Recursion in C programming

Recursion is expressing an entity in terms of itself. In C programming, recursion is achieved using functions known as recursive function. Recursive functions are very powerful in solving and expressing complex mathematical problems.

Until now, we called a function from another function. However, C language allows a function to call itself known as Recursive function.

Continue reading Recursion in C programming

C program to find maximum and minimum elements in array using recursion

Write a C program to find maximum and minimum elements in an array using recursion. How to find maximum and minimum element in an array using recursion in C programming. Logic to find find maximum or minimum elements in array in C programming.

Example

Input

Size of array: 10
Elements in array: 5, 1, 6, 10, 2, 3, 6, 50, -7, 4

Output

Maximum element = 50
Minimum element = -7

Continue reading C program to find maximum and minimum elements in array using recursion

C program to find sum of array elements using recursion

Write a C program to find sum of array elements using recursion. How to find sum of array elements using recursive function in C programming. Logic to find sum of array elements using recursion in C program.

Example

Input

Input size of array: 10
Input array elements: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Output

Sum of array: 55

Continue reading C program to find sum of array elements using recursion

C program to print elements of array using recursion

Write a C program to print all elements of array using recursion. How to display all elements of an array using recursion. Logic to print array elements using recursion in C programming.

Example

Input

Input size: 10
Input elements: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Output

Array elements: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Continue reading C program to print elements of array using recursion

C program to find GCD (HCF) of two numbers using recursion

Write a recursive function in C to find GCD (HCF) of two numbers. How to find GCD(Greatest Common Divisor) or HCF(Highest Common Factor) of two numbers using recursion in C program. Logic to find HCF of two numbers using recursion in C programming.

Example

Input

Input first number: 10
Input second number: 15

Output

HCF of 10 and 15 = 5

Continue reading C program to find GCD (HCF) of two numbers using recursion

C program to find sum of even or odd number in given range using recursion

Write a recursive function in C to find sum of all even or odd numbers in a given range. How to find sum of all even numbers between 1 to n using recursion in C programming.

Example

Input

Input lower limit: 1
Input upper limit: 100

Output

Sum of even numbers between 1 to 100 = 2550

Continue reading C program to find sum of even or odd number in given range using recursion