Can someone please help me to understand what my prof wants in this program. I am a little confused on what he wants us to put in the for loop. Here is the question:
Write a function according to the following specifications:
• The function will attempt to determine whether a sequence (array) of values are monotonically increasing; i.e., at no time is one value less than the previous one. When two or more values are the same, they are still considered to be monotonically increasing. (Any decreasing between values denotes that the sequence is not monotonically increasing.)
o Return data type: bool
o Function name: is_monotonic
o Two parameters:
- First data type: double (array)
- Parameter name: data
- Second data type: int
- Parameter name: size // i.e., how many elements are in the data array
o In the body of the function’s definition:
- Write a for-loop to iterate from element 0 until the second-to-last element. For example, if size were 10 elements, your loop would iterate from 0 to 8 (the last element, 9, is omitted because the monotonicity will be determined by comparing the current element, I, to the next element, I + 1.
- In the body of the loop, if element I is less than element I + 1, return false.
- If the iteration through the loop finishes without returning false, return true.
This is what I have so far.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include <iostream>
using namespace std;
bool is_monotonic(double data[], int size);
int main()
{
return 0;
}
bool is_monotonic(double data[], int size)
{
for ()
{
if (i < i + 1)
{
return false;
}
}
}
|
Any help would be greatly appreciated!Thank you!!