Starting from:
$30

$24

Lab #1 Solved

    • Requirements

In this lab, you will cover pass by reference and error codes. You must analyze the problem given, determine what error conditions you must test for, and make sure you code will not crash if an error condition is encountered.
Test code is provided that you may optionally use.

1.1    getAvg

int    getAvg ( int  size ,  int  * array ,  double  * result ) ;


i


Info: This function will take an integer array, an integer representing the size of the array, and a result pointer. This function will calculate the average of all the elements in the array, and place the result in the result pointer. The function must check that the size is at least 1, and that the array pointer is not NULL. The function will return -1 on error, or 0 on success.


Notice

!


Grading:


    1. Write required getAvg function * 5 points

!


Notice:


    1. All of your lab submissions must compile under GCC using the −W all and −W error flags to be considered for a grade.

    2. You are expected to provide proper documentation in every lab submission, in the form of code comments. For an example of proper lab documentation and a clear description of our expectations, see the lab policy document.


















1

More products