CS 2073 Engineering Programming
Topics and Review Questions for
Exam 2, Spring 2006


Date and length: Wednesday, 19 April 2006. The full 50-minute period: 2:00 pm - 2:50 pm.


Topics: You can find these items from the calendar under Lectures, or by using the links below. There is quite a bit of material here. To make studying easier, you should start with links in large red font.

You should also review your work for the programming assignments:


Sample Questions: I will pick simple questions about many of the topics from the web pages and from class. Often it will involve giving you some code and asking you to explain, modify, or complete the code. Here are sample questions.


Arrays: This is the most important topic since the first exam.

  1. Array initialization with curley brackets:

    Question: Use a for loop to add up the squares of the primes stored in the array in 2 above. Print the sum.
    Solution. (Don't access until you've tried the problem.)

  2. for loops and arrays: For loops go hand-in-hand with arrays, so I may use such an example as a loop to set all elements of an array to zero:

    Question: Here is a practice problem: Problem involving arrays.
    Solution. (Don't access until you've tried the problem.)

  3. Use of arrays: Write a main function that will:
    1. declare an integer array a of size 40.
    2. initialize each element a[i] with i*i.
    3. print the elements of the array.
    4. add all the elements of the array and leave the sum as a variable sum.
    5. print the value of the sum.
    Solution. (Don't access until you've tried the problem.)

  4. Use of arrays as parameters: Redo the previous problem using functions with the array as a parameter. In detail, write a main function that will:
    1. declare an integer array a of size 40.
    2. pass a to a function squares that will initialize each element a[i] with i*i.
    3. pass this initialized array a to a function printarray that will print the elements of the array.
    4. pass this initialized array a to another function addup that will add all the elements of the array and return the sum as an integer.
    5. within main print the value of the sum as returned from the function addup.
    Solution. (Don't access until you've tried the problem.)