subject

Write the following function so that it returns the same result, but does not increment the variable ptr. Your new program must not use anysquare 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 += *ptr; } ptr++;

}
return tot/nScores;

b. Rewrite the following function so that it does not use any square brackets (not even in the parameter declarations) but does use the integervariable k. Do not use any of the functions such as strlen, strcpy, etc.

// 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 str[], char chr)

{
for(intk=0;str[k]!=0;k++)
if (str[k] == chr)

}

return &str[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.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 20:00
What side length would you specify if you were required to create a regular hexagonal plate that was composed of 33 cm(squared) of sheet metal? dimension the side length to 0.1 cm
Answers: 2
question
Computers and Technology, 24.06.2019 13:30
Type the correct answer in the box. spell all words correctly. what is the default margin width on all four sides of a document? by default, the document has a margin on all four sides.
Answers: 1
question
Computers and Technology, 25.06.2019 04:00
Use the wrap text icon to modify which graphic appears in the front of layered images modify the picture effects change the way text is wrapped around an object apply wordart to the text
Answers: 1
question
Computers and Technology, 25.06.2019 08:10
Why should the technician watch for signs of contamination in the oil when recovering refrigerant from a system
Answers: 3
You know the right answer?
Write the following function so that it returns the same result, but does not increment the variabl...
Questions
question
Geography, 06.07.2019 21:00
question
Advanced Placement (AP), 06.07.2019 21:00
question
English, 06.07.2019 21:00
Questions on the website: 13722363