Question: 8.1 Lab 08 - Requirements Study the code below. Try to predict what the output will be before you run it. Part I - Using

8.1 Lab 08 - Requirements

Study the code below. Try to predict what the output will be before you run it.

Part I - Using Functions (15 pts)

See canvas for directions of getting into the csegrid

Complete zylabs 8.2 - 8.4. You will use a single main.cpp for these labs. You will create these files in csegrid, run them, then upload them to zybooks. Don't forget to submit for grading. You should make a new directory on csegrid for each of the these assignments. Work on them until they pass all tests (or as many as possible). When you are ready, don't forget to submit each one, otherwise you will not get credit.

** Part III csegrid screen shots (10 pts) **

Submit the screen shots for each of three function outputs from csegrid to canvas.

#include #include using namespace std;

void printArray(int a[], int size) { //remember arrays and vectors start at position zero for (int i=0; i

//arrays are passed by reference, so changes in the function effect the calling function void changeArray (int a[], int size, int pos, int value) { a[pos] = value; }

void printVector (vector v) { for (unsigned int i=0; i < v.size(); i++) cout << v[i] << " "; cout << endl; }

//vectors are passed by value (by default), so changes in the function do not effect the calling function void changeVectorValue (vector v, int pos, char value) { v[pos] = value; }

//vectors are passed by value (by default), but if passed by value changes in the function will effect the calling function void changeVectorReference (vector &v, int pos, char value) { v[pos] = value; } int main() { //array size must be defined before compiling int intarray1[10] = {1,2}; //with numbers arrays numbers after listed are initialized to zero vector charVector; // vectors are dynamic, so size does not have to be known before compiling cout << "Initialized Array "; printArray(intarray1, 10); cout << " after calling changeArray, with position 3 and value 9 "; printArray(intarray1, 10, 3, 9); //before accessing a vector, you must first allocate the position with a .pushback( )

//the ASCII table shows 97 is 'a' for (int i = 97; i < 123; i++) charVector.push_back(i); cout << " vector after push_backs"<

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!