write the function int secondlargest(int x[], int cap)
the function returns the second largest value in array x.assume the capacity of array x is at least 2.also assume the elemnt in the array are distinct.
exp.cpp: In function âint secondlargest(int*, int)â:
exp.cpp:4: error: âaâ was not declared in this scope
exp.cpp:6: error: âsizeâ was not declared in this scope
exp.cpp:17: error: a function-definition is not allowed here before â{â token
exp.cpp:25: error: expected â}â at end of input
im getting these errors.
#include <iostream>
usingnamespace std;
int main()
{
int arr[10];
cout<<"Enter 10 integer values and I'll sort them in ascending order\n" << endl;
for(int i=0; i<10; i++)
{
cout<< "value " <<i+1<< ":";
cin >> arr[i];
}
int i,j,temp;
for(i=0; i<10; i++)
{
for(j=0; j<10; j++)
{
if(arr[i]<arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
for(int z=0; z < 10; z++)
{
cout << arr[z] << " ";
}
cout << endl;
cout << "The second highest Number in this array " << arr[8] << endl;
return 0;
Enter 10 integer values and I'll sort them in ascending order
value 1:5
value 2:15
value 3:66
value 4:88
value 5:44
value 6:59
value 7:66
value 8:99
value 9:100
value 10:4
4 5 15 44 59 66 66 88 99 100
The second highest Number in this array 99
Process returned 0 (0x0) execution time : 11.201 s
Press any key to continue.