COM 1100 Professor Fell Quiz 3A October 9, 1997

1. Show the output of the following program.

// function prototypes
void Prob1();
void Prob2();

// definitions

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

// do the work here
	Prob1();
	cout << endl;
	Prob2();
	cout << endl;
}

void Prob1(){
	int x = 1;
	int y = 1;
	while (x < 200){
		cout << y << "   " << x << endl;
		x = 2*x + 1;
		y++;
	}
}

void Prob2(){
	int diff = 1;
	int N;
	for (N = 100; N > 0; N = N - diff){
		cout << N << " " << diff << endl;
		diff = 3*diff;
	}
}

2. Write a for loop that writes out a list of all the (non-negative) multiples of 7 that are less than 1000.

3. Write a function PaintSquare that inputs 3 integer arguments: x, y, and size and paints a square with lower left corner (x, y) and sides of length size.


Last Updated: October 11, 1997 12:29 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/QUIZ3A.html