subject

#include using namespace std;
const int SIZE = 4;
bool isSorted(const int arr[], int size);
bool isNonDecreasing(const int arr[], int size);
bool isNonIncreasing(const int arr[], int size);
void printArr(const int arr[], int size);
int main()
{
int test1[] = { 4, 7, 10, 69 };
int test2[] = { 10, 9, 7, 3 };
int test3[] = { 19, 12, 23, 7 };
int test4[] = { 5, 5, 5, 5 };
if (!isSorted(test1, SIZE))
cout << "NOT ";
cout << "SORTED" << endl;
printArr(test1, SIZE);
if (!isSorted(test2, SIZE))
cout << "NOT ";
cout << "SORTED" << endl;
printArr(test2, SIZE);
if (!isSorted(test3, SIZE))
cout << "NOT ";
cout << "SORTED" << endl;
printArr(test3, SIZE);
if (!isSorted(test4, SIZE))
cout << "NOT ";
cout << "SORTED" << endl;
printArr(test4, SIZE);
return 0;
}
bool isSorted(const int arr[], int size)
{
// TODO: This function returns true if the array is sorted. It could be
// sorted in either non-increasing (descending) or non-decreasing (ascending)
// order. If the array is not sorted, this function returns false.
// HINT: Notice that the functions isNonDecreasing and isNonIncreasing are not
// called from main. Call the isNonDecreasing and isNonIncreasing functions here.
}
bool isNonDecreasing(const int arr[], int size)
{
// TODO: Loop through the array to check whether it is sorted in
// non-decreasing (in other words, ascending) order. If the array
// is non-decreasing, return true. Otherwise, return false.
}
bool isNonIncreasing(const int arr[], int size)
{
// TODO: Loop through the array to check whether it is sorted in
// non-increasing (in other words, descending) order. If the array
// is non-increasing, return true. Otherwise, return false.
}
void printArr(const int arr[], int size)
{
for (int i = 0; i < size; i++)
cout << arr[i] << " ";
cout << endl << endl;
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 00:30
Pl i need the answer now ! which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
question
Computers and Technology, 23.06.2019 08:30
When you interpret the behavior of others according to your experiences and understanding of the world your evaluation is
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. sean is a computer programmer. he has programmed an application for toddlers that plays nursery rhymes. however, a logic error has occurred in the program. which problem is a likely consequence of the error? a. the program crashes every time the user wants to play the nursery rhymes. b. the program crosses its buffer boundaries and overwrites an adjacent program. c. the program plays a different nursery rhyme than the one the user intended to play. d. the program shows different structures in its programming language code. e. the program introduces new viruses every time the user plays a nursery rhyme.
Answers: 1
question
Computers and Technology, 24.06.2019 00:40
What is the error in the following pseudocode? module main() call raisetopower(2, 1.5) end module module raisetopower(real value, integer power) declare real result set result = value^power display result end module
Answers: 1
You know the right answer?
#include using namespace std;
const int SIZE = 4;
bool isSorted(const int arr[], int si...
Questions
question
Computers and Technology, 15.10.2019 20:40
question
Biology, 15.10.2019 20:40
Questions on the website: 13722363