top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How do I find the minimum value in an array using recursion in C language?

0 votes
505 views
How do I find the minimum value in an array using recursion in C language?
posted Oct 3, 2018 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
#indlude<stdio.h>
#define MAX_ARRAY_LENGTH 5

int minimum = 0;

void find_minimum(int arr[], int index)
{
    if(index< MAX_ARRAY_LENGTH) {
        if(arr[index]<minimum)
            minimum=arr[index];
        find_minimum(arr,++index);
    }
}

int main()
{
    int arr[MAX_ARRAY_LENGTH] = {1,2,-9,-20,43};
    find_minimum(arr,0);
    printf("minimum = %d\n", minimum);
}
answer Nov 21, 2018 by Chirag Gangdev
Similar Questions
+4 votes

Addition to this,

Can we consider "a car a man a maraca" as palindrome string?
Click here To see similar kind of palindrome strings,
Are they really a palindrome?

+1 vote

Write a recursive function:

int sum( int x, int max ) 
{ 
  /* complete the code */ 
} 

that calculates the sum of the numbers from x to max (inclusive). For example, sum (4, 7) would compute 4 + 5 + 6 + 7 and return the value 22.

Note: The function must be recursive.

...