ECE 175: Computer Programming for Engineering Applications
Page
1
of
3
Sample Problems for Midterm 2
1.
Write statements that perform each of the following tasks on a onedimensional array of size 10,
named array.
a.
Declare and initialize the element of the array to zeros
b.
Add 1 to each of the 10 elements of the array
c.
Read 10 integer values from the keyboard and store them in counts
d.
Print the mean value of all elements of counts
2.
There are 500 boxes (numbered 1 through 500) and 50 balls randomly numbered from 1 to 10 (two
or more balls may have the same number). Initially all the boxes are empty. We pick each ball one
by one and place it in the box with a number equal to the order that the ball was picked times the
number of the ball. As an example if a ball with a number 7 was picked on our 30th pick, then this
ball is placed on the box numbered 7 x 30 = 210.
Write a C program that outputs the number of
balls on each box. Assume that the ball numbers are kept in the following array:
int balls*50+ = , 4± 5± 7± 10± 3± 2± …± 8;
// the numbers in the balls are not important± hen
ce, not all of
them are listed
3.
Write a
recursive
function power (int base, int exponent) that computes the power of base to the
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '08
 Grubbs
 C Programming, Computer Programming, #include, 30 mins

Click to edit the document details