Ask Question
4 September, 02:44

Write a function named lastGreater that takes three arguments and returns in integer. The first argument is an integer array. The second argument is the length of the array. The third argument is an integer comparison value. Return the index of the lastelement in the array that is greater than the comparison value. If there is no element in the array greater than the comparisonvalue, then return - 1.

+4
Answers (1)
  1. 4 September, 02:55
    0
    See explaination for the code

    Explanation:

    #include

    #include

    int lastGreater (int a[], int len, int co)

    {

    int i, lar=-1;

    for (i=0; i
    {

    if (a[i]>co)

    {

    lar=a[i];

    }

    }

    return lar;

    }

    void main ()

    {

    int a[]={1,7,5,9,4};

    int c=5, n=5, lar;

    lar=lastGreater (a, n, c);

    printf ("Last Large number in array is %d", lar);

    getch ();

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a function named lastGreater that takes three arguments and returns in integer. The first argument is an integer array. The second ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers