practice_problems_mid2 - ECE 175: Computer Programming for...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
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 one-dimensional 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
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/06/2010 for the course ECE 175 taught by Professor Grubbs during the Spring '08 term at University of Arizona- Tucson.

Page1 / 3

practice_problems_mid2 - ECE 175: Computer Programming for...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online