Explore BrainMass
Share

C++ Function Declaration

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Please show all work.

Here are the problems:

2. Given the following function declaration, fill in the body so that the function will return 5 times the parameter squared plus 22.7 times the parameter minus 17.6
double funTwo (double x)
// your code here
return z
end function funTwo
3. Given the following function declaration, fill in the body so that the function will return the sum of the integers between the first and second parameters, inclusive. You may assume that the first parameter is less than the second.
int funThree (int m, int n)
// your code here
return a
end function funThree
4. Given the following function declaration, fill in the body so that the function will return the greatest common divisor of the two parameters. You may assume that the parameters are both greater than 0.
int funFour (int a, int b)
// your code here
return z
end function funFour
6. Given the following function declaration, fill in the body so that the function will return the sum of the squares of the integers between the two parameters, inclusive. You may assume that the first parameter is less than the second.
int funSix (int x, int y)
// your code here
return z
end function funSix
8. Given the following function declaration, fill in the body so that the function will return true if the parameter is a multiple of 7. You may assume that the parameters is greater than 0.
boolean funEight (int x)
// your code here
return z
end function funEight
9. What is the output of the following function call, given the function shown after main?
main
write nufOne (10)
end main

int nufOne (int n)
int z = 2*n*n*n + 7*n*n + 4*n + 8
return z
end function nufOne
12. What is the output of the following function call, given the function shown after main?
main
nufFive (1, 3, 12)
end m

void nufFive (int a, int b, int c)
int n
for n = a step b to c
write n, ": ", nufFive (n)
end for
end nufFive

int nufFour (int k)
int z = 2*k + 7
return z
end function nufFour
14. What is the output of the following function call, given the function shown after main?
main
int n, m
for n = 1 step 2 to 10
nufSix ()
end for
write newLine
for m = 3 step 4 to 12
nufSix ()
end for
write newLine
end main

void nufSix ()
write "*" // no new line here
end nufFive.

© BrainMass Inc. brainmass.com October 25, 2018, 12:51 am ad1c9bdddf
https://brainmass.com/computer-science/cpp/cplusplus-function-declaration-243392

Solution Preview

Problem #2
double funTwo(double x)
double z = 5*x*x + 22.7*x - 17.6;
return z;
end function funTwo

Problem #3
int funThree(int m, in n)
int a = 0;
for (int b=m; b<=n; b++) a += b;
return a;
end function funThree

Problem #4
int funFour(int a, int b)
int a1 = a;
int b1 = b;
while (a1%b1 != 0) {
int a1 = a1%b1;
// swap a1 and b1
int temp = b1;
b1 = ...

Solution Summary

C++ function declaration is examined in the solution.

$2.19
See Also This Related BrainMass Solution

Data Structures C++

Consider the following statement:

class strange
{
.
.
.
};

a. Write a statement that shows the declaration in the class strange to overload the operator >>.
b. Write a statement that shows the declaration in the class strange to overload the binary operator + as a member function.
c. Write a statement that shows the declaration in the class strange to overlaod the operator == as a member function.
d. Write a statement that shows the declaration in the class strange to overload the postincrement operator ++ as a member function.

View Full Posting Details