burton95
- 54
- 0
Hi there- I'm trying to check an array for ascending order and if not to print out the number that is out of order by using a function. I solved it by not using a function but when I've tried to use a fxn for some reason it tells me that in my call for the fxn the numbers "argument of type int is incompatible with parameter of type int"?
Code:
#include <iostream>
using namespace std;
int out_of_order(int a[], int size);
const int amount_of_numbers = 5;
int main()
{
int numbers;
int a[] = { 2, 7, 6, 8, 12 };
int number_out_of_order = out_of_order([B]numbers[/B], amount_of_numbers);
cout << number_out_of_order;
}
int out_of_order(int a[], int size)
{
for (int i = 0; i < size - 1; i++)
if (a[i] > a[i + 1])
return i+1;
else
return -1;
}
Last edited: