COM 1100 Professor Fell Quiz 8A November 13, 1997

void WriteArray(int A[], int N);

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

	//Problem 1----------------------------variables and assignment, cout
	int x = 5, y = 7, z = 9;
	cout << x << ' ' << y << ' ' << z << endl;
	x = y + z;
	y = x + z;
	z = x + y;
	cout << x << ' ' << y << ' ' << z << endl;
	x = z - y;
	y = z - x;
	z = y - x;
	cout << x << ' ' << y << ' ' << z << endl;
	cout << endl;
	cout << endl;
	
	//Problem 2----------------------------------------integer arithmetic
	int A = 5, B = 7, C;
	C = A - B / 3 + A / 2;
	cout << A << ' ' << B << ' ' << C << endl;
	
	C = 10;
	cout << A++ << ' ' << B++ << ' ' << C++ << endl;
	cout << A++ << ' ' << B++ << ' ' << C++ << endl;
	cout << endl;
	
	A = 5, B = 7;
	C = A / (B / A) * B;
	cout << A << ' ' << B << ' ' << C << endl;
	cout << endl;
	
	//Problem 3-----------------------------------------------------loops
	//Write a loop with this output:
	//     6405 * 1601 * 400 * 100 * 25 * 6 * 1 
	
	//Problem 4-------------------------------------------------functions
	// Write a function RectangleArea that has arguments width and height of 
	// type double and returns the area of the rectangle with that width and height. 

	//Problem 5--------------------------------------------------function
	// Write a function IsOp returns true if and only if its char argument
	// is '+', '-', '*', or '/'.
	
	//Problem 6----------------------------------------------------arrays
	int AA[8] = { 3, 5, 4, 2, -1, 7, 0, 6 };

	for (int J = 0; J < 8; J++)
		if (AA[J] < 1) AA[J] = 1;
	WriteArray(AA, 8);
	
	for (int J = 0; J < 4; J++)
		WriteArray(AA, J);

}

void WriteArray(int A[], int N){
	for (int J = 0; J < N; J++)
		cout << J << ' ' << A[J] << endl;
	cout << endl;
}


Last Updated: November 16, 1997 12:44 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/QUIZ8A.html