/* This program illustrates array, passing array as fucntion parameters * Author: Xiaolan Zhang * Date: Dec 2, 2022 * Known bugs: to be found */ #include using namespace std; const int CAPACITY=100; void PrintArray (const int a[], int size); void ReadData (int a[], int & size); void CopyArray (const int src[], int size, int dest[], int & dest_size); //These functions are declared, but they have an emtpy body right now below. //please implement them one-by-one //Multiply each array element by the factor void MultiplyData (int a[], int size, int factor); //search for value in the (partially-filled) array int Search (const int a[], int size, int value); //Is the values in the array sorted in ascending order or not? bool IsSorted (int a[], int size); int main() { int data[CAPACITY]; int size=0; //how many data are stored in the array int value; PrintArray (data,size); //Exploring array and address concepts //Read a sequence of integer from keyboard (end with Q) // save them to data array, and also set size ReadData (data,size); /* This part of code is used to illustrate array and address cout <<"data's value" << data <> value; int index= Search (data, size,value ); cout <<"Search result:"<> value; index= Search (data, size,value); cout <<"Search result:"<> a[size]) //cin >> a[size] will be true if we read an int successfully size++; else //user enters Q encounterQ = true; } while (!encounterQ && size!=CAPACITY); cin.clear (); //clear the failure flag in cin cin.ignore (1000, '\n'); //ignore the content in the input buffer, //all the way until the newline char } void MultiplyData (int a[], int size, int factor) { //Todo by you } //Search for value in the array, return the location/index of the value //in the array; if the value does not appear in the array, return -1 int Search (const int a[], int size, int value) { //this is a stub, i.e., return -1; } //Is the values in the array sorted in ascending order or not? //for example, if a[] stores 1, 3, 10, 10, 12, ... all values are //stored so that values are arranged from smallest to largest.. bool IsSorted (int a[], int size) { return false; //please replace this by your implementation. }