Question: 1. Research and write below the prototype of the s... SOLVED

Question: 1. Research and write below the prototype of the s... SOLVED

1. Research and write below the prototype of the standard C++ function which converts a character to a lowercase form of the same character.

2. In several standard C++ functions the return type often will not be what you need. What would you need to use the above function as a way to generate a lowercase character for a cout statement?


3. List the two categories of user–defined functions that the book describes:


4. Function prototypes and function definitions look similar because they have the same function heading. In a function prototype the heading is followed by a ___, whereas in a function definition the heading is followed by a ___.


5. What are the two forms of passing arguments to a function?


6. In C++ it is said that functions have only one return type. What mechanism allows programmers to work around this limitation?

7. Based on the above the answer, which of the following two function prototypes makes sense to use for a function that will swap two values, the first or second?
void swap(int val1, int val2); //prototype #1
void swap(int& val1, int& val2); // prototype #2


8. Write a function definition as follows: it returns the C++ form of a Boolean value, its function identifier is anyTwoTheSame, it has three formal parameters which all are floating-point values, and the body of the function returns true if any two of the parameters are equal, otherwise it returns false. I recommend using short, simple identifiers for the three formal parameters.


9. (yes/no) In C++, is it legal to declare the variable int v; at the top of the body of a function and later declare char v; inside of a while loop body? (Book review question on scope.)
//example function body template
{
int v;

while(…)
{
char v;

}

}

Answer:

10-13. Consider the following function definition: void defaultParam(int num1, int num2 = 7, double z = 1.5){ int num3; num3 = static_cast<int(z) + num2 – num1; cout << "num3 = " << num3 << endl;}What is the output of the following function calls?10. Case one: defaultParam(7);
Output:
11. Case two: defaultParam(-7, -8);

Output:

12. Case three: defaultParam(0, 1, -7.5);
Output:
13. Case four: defaultParam(4, -4, -1.3);
Output:
Powered by