COM 1100 Professor Fell Quiz 9B November 20, 1997

```void B(short M);

void main()
{	BigConsole();

//Problem 1----------------------------variables and assignment, cout
int x = 3, y = 5, z = 7;
cout << x << ' ' << y << ' ' << z << endl;
x += y;
y += z;
z += x;
cout << x << ' ' << y << ' ' << z << endl;
x = z - x;
y = z - y;
z = z - x - y;
cout << x << ' ' << y << ' ' << z << endl;
cout << endl;

//Problem 2-----------------------------------------------------loops
// Write a for loop that writes all the positive integers that are
// perfect squares and less than 500.

//Problem 3--------------------------------------------------functions
// Write a function SphereArea that takes an argument R of type double
// and returns the surface the sphere with radius R.  (A = 4ıR^2)

//Problem 4---------------------------------------strings & functions
// Write a function NumDigits that takes a string argument and returns the
// number of digits (0 .. 9) in the string.  (e.g. NumDigits("Da5id 3rd") is 2.)

//Problem 5--------------------------------------------array-function
cout << 2 << "   ";
B(2);
cout << 5 << "   ";
B(5);
cout << 14 << "   ";
B(14);

//Problem 6--------------------------------------------binary numbers
//Give the decimal equivalent of each of the following binary numbers:
//
//	01100100
//	01010101
//	01111000
}

void B(short M){
int A[16];
int place;
for (place = 0; M > 0; place++){
A[place] = M % 2;
M /= 2;
}
for (place--; place >= 0; place--)
cout << A[place];
cout << endl;
}

```

Last Updated: November 23, 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/QUIZ9B.html