COM 1100 Professor Fell Quiz 4A October 16, 1997

Use the windows below to show the output of the following code:
(The grid boxes are 20 pixels apart.)

```// function prototypes
int F(int x, int y);
void Conway(int N);
void Circles();

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

//Problem 3----------------------
cout << "Problem 1" << endl;
Conway(8);
cout << endl;
Conway(3);
cout << endl;

//Problem 3----------------------
int x = 1;
int y = 5;
cout << "Problem 2" << endl;
cout << endl;
for (int j = 1; j <=5; j++){
cout<< j<<" "<< x<<" "<< y<< endl;
x = F(x, y);
y = F(x, y);
}

//Problem 3----------------------
Circles();

PressReturn();
} // end main

int F(int x, int y){
if (x < y)
return 2*x;
else
return 2*y;
}

void Conway(int N){
if (N <= 0 )
cout << "error" <<endl;

while (N > 1){
cout << N << endl;
if ((N % 2) == 0)
N = N/2;
else
N = 3*N + 1;
}
cout << N << endl;
}

void Circles(){
int x = 10, r = 10;

while (x + r < 200){
FrameCircle(x, 100, r);
x = x + r;
r = 2*r;
x = x + r;
}
}
```

Problem 4.
Write a C++ function that takes two int arguments and returns their average.

Last Updated: October 19, 1997 9:03 am 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/QUIZ4A.html