Hello, I want to write a function named printAscending, that will take an int array and the length as its input and output each integer on a line that is greater than the last. If one is smaller it will drop to a new line and continue from there:
input {2, 5, 8, 3, 9, 9, 7}
output:
2, 5, 8
3, 9, 9
7
I'm not sure how to code this. I would need for it to know when to drop to a new line. Some clarification/assistance would be much appreciated.
void printAccending(int my_array[], int i)
{
for (int i = 0; i < 7; i++)
}
int main()
{
int my_array[] = {2, 5, 8, 3, 9, 9, 7};
You want to loop through the entire array, and check each element if it is less than the last. If that condition is true, you output a newline before outputting the number. You're going to need to use if statements in the for-loop of your printAscending function.