CS211 Midterm 1 Review Guide

The test will be on paper, available Wednesday, Feb 25, through Sunday, March 1, but our testing center is not open during the weekend. 10 pages of notes are allowed, 8.5 by 11, both sides. Some things I'd suggest for your notes:

Test Topics

Test Layout

The test will have a page of multiple choice, three points per question with 8 questions. After that, the rest of the test will be short answer format. Questions will ask for either a short answer in English, a short piece of code, or the output for some code, or a correction or amendment to some code.

Example Questions

Short answer: What does the following program print out?
#include <iostream>
using namespace std;

int main(){
	int gerbil = 23;
	int gerbil_mites = gerbil / 5;
	int gerbil_hairs = gerbil % 5;
	cout << gerbil_mites << endl; 
	cout << gerbil_hairs << endl; // Remember endl in your answer
	return 0;
}
Short answer: What does the following program print out?
#include <iostream>
using namespace std;

string hamster(string message){
	for(int i = 0; i < message.length(); i++)
		if(message[i] == ' ')
			message[i] = '_';
	return message;
}

int main(){
	string ham = "I'm stuck in a cage!"
	cout << hamster(ham) << endl;
	cout << ham << endl; // Might save this for the second midterm
	return 0;
}
Short answer: Write a program that will read a two numbers from the user, a number of volts and a number of amps. The program will multiply these two numbers together, and print the result followed by the word "watts". The interaction with the user should look like this:
Enter the number of volts:   100
Enter the number of amps:  1.5
The power is 150 watts

Coding on the test

For the test, you'll have to write some code on paper. Please try to be as neat as possible! Make sure your code is close enough to something that compiles and works that it looks like you know what you're doing.