COM 1100 Professor Fell Quiz 3B 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 < 100){
		cout << y << "   " << x << endl;
		x = 2*x + y;
		y++;
	}
}

void Prob2(){
	int D = 1;
	int M;
	for (M = 0; M < 2000; M = 2*M + D){
		cout << M << " " << D << endl;
		D = 10*D;
	}
}
2. Write a for loop that writes out a list of all the positive, integral powers of 2 that are less than 1000.

3. Write a function Poly that inputs an argument double x and returns the value of

3x2 + 2x + 5

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