Ask Question
9 March, 15:20

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.

+1
Answers (1)
  1. 9 March, 17:16
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers