Assignment 8 - Assignment #8 CS 170A, Spring 2006 Due...

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

View Full Document Right Arrow Icon
Assignment #8 CS 170A, Spring 2006 Due Tuesday, March 14 Part 1 (practice exercises) 1. Read chapter 9 in the text. 2. Do review questions 4–7 on p.439–441. Part 2 (to turn in) 1. Declare and define a templatized function, called ArraySum , that returns the result of adding the elements in an array that are within a specified range. Do not make any assumptions about the data type of the array, except that the values may be zero–initialized and may be added using the binary + operator (in particular, you should not assume that the += operator can be used). The range of array elements that are to be summed should be specified by using two pointers : a pointer to the first element of the range, and a pointer to one after the last element of the range. Specifically, the code fragment int a[10] = {0,1,2,3,4,5,6,7,8,9}; int s = ArraySum(a,a+10}; should set the value of s to be the sum of all the elements in the array a , namely 45. Similarly, the code fragment float b[5] = {1.0f,2.0f,3.0f,4.0f,5.0f};
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.

Page1 / 2

Assignment 8 - Assignment #8 CS 170A, Spring 2006 Due...

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