Question: c++ 3. a. Rewrite the following function so that it returns the same result, but does not increment the variable ptr. Your new program must

c++
c++ 3. a. Rewrite the following function so that it returns the
same result, but does not increment the variable ptr. Your new program

3. a. Rewrite the following function so that it returns the same result, but does not increment the variable ptr. Your new program must not use any square brackets, but must use an integer variable to visit each double in the array. You may eliminate any unneeded variable. double computeAverage (const double* scores, int nScores) const double* ptr scores; double tot - 0; while (ptr - scores + nScores) tot +- *ptri ptr++; return totScores: b., Rewrite the following function so that it does not use any square brackets (not even in the parameter declarations) but does use the integer variable k. Do not use any of the functions such as strlen, strcpy, etc. 17 This function searches through str for the character chr. // If the chr is found, it returns a pointer into str where // the character was first found, otherwise nullptr (not // found). const char* findTheChar (const char stri), char chr) for (int k = 0; str[k] ! 0; k++) if (str[k] =* chr) return estr[k]; return nullptr; c. Now rewrite the function shown in part b so that it uses neither square brackets nor any integer variables. Your new function must not use any local variables other than the parameters

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!