Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help Will rateLifesaver!!!!! Write three functions. The first function will acce

ID: 3614998 • Letter: H

Question

Help Will rateLifesaver!!!!! Write three functions.

The first function will accept an array and size as parameters andrecursively find the largest element in the array.

The second function will accept an array and size as parameters andrecursively find the smallest element in the array.

Using one of these methods and a stack or queue definition, write afunction which will accept an array and size as parameters and sortthe array in ascending order.

The third function you write will accept a String as a characterarray and print the characters in reverse Help Will rateLifesaver!!!!! Write three functions.

The first function will accept an array and size as parameters andrecursively find the largest element in the array.

The second function will accept an array and size as parameters andrecursively find the smallest element in the array.

Using one of these methods and a stack or queue definition, write afunction which will accept an array and size as parameters and sortthe array in ascending order.

The third function you write will accept a String as a characterarray and print the characters in reverse

Explanation / Answer

#include<iostream>
#include <cstdlib>

using namespace std;
int find_max(int *arr,int s)
{
int temp;   
    if(s<=1)
    return arr[0];
    else
    if(arr[s-1]> arr[s-2])
    {
    temp = arr[s-1];
    arr[s-1]=arr[s-2];
    arr[s-2] = temp;
    }
    return find_max(arr,s-1);
   
}

int find_min(int *arr,ints)
{
    int temp;
    if(s<=1)
    return arr[0];
    else
    if(arr[s-1]< arr[s-2])
    {
    temp = arr[s-1];
    arr[s-1]=arr[s-2];
    arr[s-2] = temp;
    }
   
    return find_min(arr,s-1);
   
}
void print_rev(char *str)
{
     int len,i;
     len=strlen(str);
     for(i=len-1;i>=0;i--)
     printf("%c",str[i]);
    
     printf(" ");
}
int main(){
    int i;
    int arr[]={1,6,4,2,8};
    cout<<"max is:"<<find_max(arr,5)<<endl;
    cout<<"min is:"<<find_min(arr,5)<<endl;
   
    for(i=0;i<5;i++)
     find_min(&arr[i],5-i);
     printf(" Ascending order list:");
     for(i=0;i<5;i++)
     printf(" %d",arr[i]);
    
     printf(" reverse of hello is:");
     print_rev("hello");
system("pause");
    return 0;
}