COM 1100 Professor Fell Quiz 7A November 6, 1997

Show the output of the following program:

```// function prototypes
void Flipper(int& x, int& y, int z);
void Swap(int& A, int& B);
int Summer(int M, int N, int ARRAY[]);

void main()
{// open text and drawing windows
BigSquarePair();

// Problem 1----------------------------------
cout << "Problem 1" << endl;
int A[8] = { 10, 5, 3, 1, 2, 4, 6, 8 };
cout << Summer(3, 5, A) << endl;
cout << Summer(0, 6, A) << endl;
cout << Summer(6, 3, A) << endl;
cout << Summer(5, 5, A) << endl;
cout << endl;
// Problem 2----------------------------------
cout << "Problem 2" << endl;
int P = 5, Q = 7, R = 2;
Flipper(P, Q, R);
cout << P << ' ' << Q << ' ' << R << endl;
Flipper(Q, R, P);
cout << P << ' ' << Q << ' ' << R << endl;
Flipper(R, P, Q);
cout << P << ' ' << Q << ' ' << R << endl;
cout << endl;
// Problem 3----------------------------------
cout << "Problem 3" << endl;
int B[5] = { 10, 5, 3, 1, 4};
for (int J = 0; J < 4; J++)
Flipper(B[J], B[J+1], 2);
for (int J = 0; J < 5; J++)
cout << J << ' ' << B[J] << endl;
cout << endl;
//--------------------------------------------
PressReturn();
}

void Flipper(int& x, int& y, int z){
cout << "Start Flipper x = " << x << " y = " << y << " z = " << z << endl;
if (x < y) Swap(x, z);
else       Swap(y, z);
cout << "End Flipper x = " << x << " y = " << y << " z = " << z << endl;
}

void Swap(int& A, int& B){
int T = A;
A = B;
B = T;
}

int Summer(int M, int N, int ARRAY[]){
int S = 0;
for (int J = M; J < N; J++)
S += ARRAY[J];
return S;
}
```
Problem 4: Write a C++ function whose arguments are and array of char an an integer N and that returns the number of characters in the first N positions the array that are uppercase letters.

Last Updated: November 9, 1997 10:01 pm by
Harriet Fell
College of Computer Science, Northeastern University
360 Huntington Avenue #161CN,
Boston, MA 02115
Internet: fell@ccs.neu.edu
Phone: (617) 373-2198 / Fax: (617) 373-5121
The URL for this document is: http://www.ccs.neu.edu/home/fell/COM1100/QUIZ/QUIZ7A.html