The questions for exam 1 will be taken from/similar to/based on the following, and on labs and projects you've completed so far, and on the self-check questions from Chapters 1-5 of Mercer.
 
1. Identify the following: 2. Determine what the following IBM program does. Assume a 3-digit number is stored in memory location 40.
  930
  040
  940
  940
  950
  950
  180
  040
  940
  950
  950
  181
  040
  950
  950
  182
  920

3. Write a program in IBM assembler to read in two characters, subtract the code of the smaller from the code of the larger, and display the result as a two-digit number in screen locations screen1 (tens digit) and screen2 (ones digit).

4. Explain the fetch/execute cycle of the Itty Bitty Machine.

5. Write a C++ program to read three (double) values from a user, sum them, compute their average, and print it.

6. Let a and b be values of type int. Write an expression with a value equal to b in terms of b/a and b%a.

7. Write the function heading for the function getValue, which takes a string argument and returns a double.

8. Why does the following code fragment produce errors? Identify two separate errors:

double twoParms(string a, double b) {
    .
    .
    .
}

    .
    .
    .
int a,b;
double x(7.2);
string str("blah blah");

a = twoParms(x, str);
    .
    .
    .

9. Give the analysis and design of a program that reads in the two lengths of the two shorter legs of a right triangle and compuptes the length of the hypotenuse.

10. Self-check problem 2-15, p. 57 in Mercer.

11. Consider the following declaration:

string myStr("This is a long string.");
What is the value of the following? (Be careful!)
myStr.find("is");
Write an expression that inserts another copy of the string " long " (note spaces) into any string containing it. The resulting string should include " long long " where the original string had " long ".

12. Write a function getValue that takes a string as an argument. getValue prints the string, reads a value of type double from input, and returns that double value. Be sure to specify pre- and postconditions in your implementation.

13. Write a function computeSalesTax that takes two arguments of type double, the first being a sales tax rate, the second being a purchase amount. computeSalesTax computes the sales tax by multiplying these values together, and returns the product.

14. What is the output of the following program? Show the environments of the function calls.

#include <iostream>

int f1(int j)
{
    int k = 5;
    j = k * j;
    cout << "f1: " << j << endl;
    return j;
}

int f2(int k)
{
    k = 2 * f1(k);
    cout << "f2: " << k << endl;
    return k;
}

int main()
{
    int j = 1, k = 2;

    cout << "j = " << j << "; k = " << k << endl;
    k = f2(j);
    cout << "j = " << j << "; k = " << k << endl;

    return 0;
}

15. What is the relavance of the per and post conditions for a function?

16. What does it mean for two types to be compatible?

17. What restrictions are there on an assignment statement relative to types?

18. What is meant by the type of an expression and how is it determined for a particular expression?

19. Do an analysis, design, and implementation for a function which is to take two strings and return the new string obtained by concatenating the first half of the first string to the second half of the second string.