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, 21.06.2019 22:30
Ted wants to go out to a neighborhood park and shoot pictures of dew drops on grass. he wants to get a low-level angle of the dew drops. which support equipment should ted use? a. mini tripod b. pistol grip c. monopod d. body mount
Answers: 2
question
Computers and Technology, 23.06.2019 03:00
State 7 common key's for every keyboard
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
What is the penalty for violating section 1201 of title 17 chapter 21 of the us code
Answers: 1
question
Computers and Technology, 23.06.2019 17:10
Ac++an of of pi. in , pi is by : pi = 4 – 4/3 + 4/5 – 4/7 + 4/9 - 4/11 + 4/13 - 4/15 + 4/17 . ., to pi (9 ). , if 5 to pi,be as : pi = 4 - 4/3 + 4/5 - 4/7 + 4/9 = 4 – 1. + 0.8 - 0. + 0. = 3.. atoofbe to pi?
Answers: 2
You know the right answer?
Write the following function so that it returns the same result, but does not increment the variabl...
Questions
Questions on the website: 13722362