COM 1100 Professor Fell Quiz 9A 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 = z - x;
y = z - y;
z = z - x - y;
cout << x << ' ' << y << ' ' << z << endl;
x += z;
y += z;
z += x + y;
cout << x << ' ' << y << ' ' << z << endl;
cout << endl;

//Problem 2-----------------------------------------------------loops
// Write a loop that writes all the positive integers
// less than 100 that are divisible by 7, one per line.

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

//Problem 4---------------------------------------strings & functions
// Write a function NumLetters that takes a string argument and returns
// the number of letters in the string. (e.g. NumLetters("Da5id") is 4.)

//Problem 5--------------------------------------------array-function
cout << 3 << "   ";
B(3);
cout << 6 << "   ";
B(6);
cout << 11 << "   ";
B(11);

//Problem 6--------------------------------------------binary numbers
//Give the decimal equivalent of each of the following binary numbers:
//
//	01001100
//	01110101
//	00001111
}

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/QUIZ9A.html