Name: ______________________ Honor Code Acknowledgment: _____________ Random Quiz # 2 CPS 100E, Fall 1995 Due: September 12, 1995 Problem 1: Acch, ptooey (3 pts) The function atoi in converts a string to an integer. However, the value of atoi("dog") is 0. Suppose that you don't have access to so that you must write your own version of atoi. Do this using the header below. The function doesn't have to work with negative numbers, but you get extra credit if it does. The intOk parameter is set to true if the string passed is a valid integer (all digits) and is set to false if the string is NOT a valid integer. Thus atoi("123",x,y) should result in x getting the value 123 and y getting the value true; whereas atoi("12a3",z,w) should result in w getting the value false (the value of z in this case can be anything). void atoi(string s,int & value, bool & intOK) // postcondition: value = integer represented by string s // intOk = true if s represents a valid integer // otherwise intOk = false Problem Array Max (2 pts) Write the function MaxValue that returns the largest value stored in the first num locations of the array a. int MaxValue(const Vector & a, int num) // precondition: a contains num values // postcondition: returns the largest of the values stored in a