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 06:30
This technology is used to produce high-quality documents that look good on the computer screen and in print. wiki presentation paint desktop publishing
Answers: 3
question
Computers and Technology, 23.06.2019 04:31
Q13 what function does a security certificate perform? a. creates user accounts b. scrambles data c. identifies users d. creates password policies e. provides file access
Answers: 1
question
Computers and Technology, 24.06.2019 11:30
Convert 11001110(acdd notation) into decimal
Answers: 2
question
Computers and Technology, 25.06.2019 08:50
The purpose of this problem is to write some small functions and practice passing things around amoung functions.1) the main function shall ask the user to enter three numbers and read the three numbers.2) write a function named findsum that takes three numbers as arguments and returns their sum. the main function shall call this function.3) write a function named findaverage that takes the sum and the number of numbers and returns the average. the main function shall call this function.4) write a function named findsmallest that takes the three numbers and returns the smallest value. the main function shall call this function.5) the main function shall print the results in the following format, with two decimal positions and the decimal points aligned:
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
Mathematics, 12.05.2021 05:30
question
Mathematics, 12.05.2021 05:30
question
Mathematics, 12.05.2021 05:30
question
Mathematics, 12.05.2021 05:30
Questions on the website: 13722367