COM 1100 Professor Fell Homework Exercises 1 Solution

Problems 1, 2, 3, and 4 Problem 5:Construct a logical expression to represent each of the following conditions:

Problem 6:

int min3(int x, int y, int z){
	if ((x <= y) and (x <= z )) 
		return x;
	if ((y <= x) and (y <= z )) 
		return y;
	return z;			
}

Problem 7:

bool GetCircleData(int& x, int& y, int& radius){
	cout << "Enter circle data:  x  y  radius" << endl;
	cin >> x >> y >> radius;
	return (radius >= 0);
}

Problem 8:

 
void extremes(int& min, int& max, int A[], int n){
	min = A[0];		// start min and max with values that occur in the array
	max = A[0];
	
	for (int J = 1; J < N; J++){
		if (A[J] < min)
			min = A[J];
		else if (A[J] > max)
			max = A[J];
	}
}


Last Updated: November 16, 1997 12:17 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/HW/Exercises1Solution.html