COM 1100 Professor Fell Quiz 9B Solution

Problem 1

3 5 7
8 12 15
7 3 5

Problem 2

for (int K = 1; K*K < 500; K++)
		cout << K*K << endl;

Problem 3

double SphereArea(double R){
	return 4*pi*R*R;
}
Problem 4
int NumDigits(string s){
	int count = 0;
	for (int K = 0; K < s.length(); K++)
		if (('0' <= s[K]) and (s[K] <= '9'))
			count ++;
	return count;
}
Problem 5

2 10
5 101
14 1110

Problem 6

01100100binary = 64 + 32 + 4 = 100decimal
01010101binary = 64 + 16 + 4 + 1= 85decimal
01111000binary = 64 + 32+ 16 + 8 = 120decimal


Last Updated: December 5, 1997 9:21 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/Q9BSolution.html