Question: 1 3 . 2 3 LAB: What order? ( function templates ) Define a generic function called CheckOrder ( ) that checks if four items

13.23 LAB: What order? (function templates)
Define a generic function called CheckOrder() that checks if four items are in ascending, neither, or descending order. The function should
return -1 if the items are in ascending order, 0 if the items are unordered, and 1 if the items are in descending order.
The program reads four items from input and outputs if the items are ordered. The items can be different types, including integers, strings,
characters, or doubles.
Ex. If the input is:
bat hat mat sat
{:[63.2,96.5,100.1,123.5]
the output is:
Order: -1
order: -1
main.cpp
using namespace std;
// TODO: Define a generic method called Checkorder() that
??? takes in four variables of generic type as arguments.
// The return type of the method is integer
// Check the order of the input: return -1 for ascending,
??0 for neither, 1 for descending
int main()[
??? Read in four strings
string stringArg1, stringArg2, stringArg3, stringArg4;
cin stringArg1;
cin stringArg2;
cin stringArg3;
cin stringArg4;
// Check order of four strings
cout "Order: " Checkorder(strinqArq1, strinqArq2, strinqArq3, strinqArq4) end1;
 13.23 LAB: What order? (function templates) Define a generic function called

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!