C program to list all files in a directory recursively

Write a C program to list all files in a directory. How to list all files in a directory recursively. How to use readdir() function to list all files in a directory recursively. Logic to list all files and sub-directories of a directory in C programming. How to use opendir(), readdir() and closedir() library functions.

Read more

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.

Read more

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

Read more

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

Read more

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

Read more

Function, recursion programming exercises and solutions in C

A function is a collection of statements grouped together to do some specific task. In series of learning C programming, we already used many functions unknowingly. Functions such as – printf(), scanf(), sqrt(), pow() or the most important the main() function. Every C program has at least one function i.e. the main() function.

Function provides modularity to our program. Dividing a program in different modules makes it easy to maintain, debug and understand the code.

Read more

C program to find LCM of two numbers using recursion

Write a C program to find LCM of two numbers using recursion. How to find LCM of two numbers in C programming using recursion. Logic to find LCM of two numbers using recursion.

Example

Input

Input first number: 12
Input second number: 30

Output

LCM of 12 and 30 = 60

Read more

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

Read more

C program to find sum of digits using recursion

Write a recursive function in C programming to calculate sum of digits of a number. How to calculate sum of digits of a given number using recursion in C program. Logic to find sum of digits using recursion in C programming.

Example

Input

Input number: 1234

Output

Sum of digits: 10

Read more

C program to check palindrome number using recursion

Write a recursive function in C to check palindrome number. How to check whether a number is palindrome or not using recursion in C program. Logic to check palindrome number using recursion in C programming.

Example

Input

Input number: 121

Output

121 is palindrome

Read more