CS273

Quiz 1 Solution

 

Put your social security number in the right hand corner of the page.  Please do not put your name anywhere on this quiz.  You will have until the end of class to complete the quiz.

 

1. (5 points) Give below pseudocode defining a function with two parameters:

a)      an array of n elements of type double.

b)      n number elements in the array.

    The functions should add all the elements in the array and return the result.

 

            double addfun (double arr[], int n)

            {

                   double sum = 0.0;

                   int i;

 

                   for(i=0; i<n; i++)

                         sum += arr[i];

                 

                   return sum;

             }