C++ ch9 extra Word Scramble
|
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.
Normal Size Small Size show me how
Normal Size Small Size show me how
| Question | Answer |
| What two reasons do programmers use functions for? | (1) so there is less duplication of code(2) to allow large and complex programs to be broken into small and manageable tasks. |
| The main function returns its one value to the ___. | oeprating system. |
| The ___ function returns a string of characters entered by the user at the keyboard. | getline() |
| The ___ function returns the uppercase equivalent of a string. | toupper() |
| What is the syntax of the pow function? Explain. | pow(x, y)x is the number you want raised to power y. |
| To use the pow function ins a program, the program must contain the __ directive? | #include <cmath> |
| cube = pow(4.0, 3) Explain | The double 4.0 is raised to the third power(4.0 * 4.0 * 4.0) and the answer is assigned to the cube variable. |
| What is the syntax to specifiy the range of a random number? Write the formula for a range of 1 -6 | lowerbound + rand() % (upperbound - lowerbound + 1)1 + rand() % (6 - 1 + 1); |
| Show and explain the syntax of the srand function. | srand(seed)seed is an integer that represents the starting point for the random number generator. |
| Most C++ programmers use the built-in __ function as the -seed-. | time() |
| A program uses the statement discount = calcDisc(300.45); to call the calcDisc functions, which returns a number having a decimal place. Which is a valid function header for the calcDisc function? | double calcDisc(double sales) |
| Most C++ programmers enter the function definition where? | below the main function in a program. |
| A function prototype can be thought of as the ? | table of contents in a book. (simply a preview of what will be expanded on later) |
| What is the syntax of a function prototype? Give an example. | returnDataType functionName(parameterList);int calcRectangleArea(int, int); |
| What is the difference between a function header and a function prototype? | (1) A function prototype ends with a semicolon.(2)The function header contains both the data type and name of each formal paramter, but the function prototype contains only the data type. |
| The function prototype is necessary only when ? | the function is defined after the main() function. |
| The formal parameters are defined in the ? | function definitions |
Created by:
kat1350
Popular Computers sets