click below
click below
Normal Size Small Size show me how
03 mod 7
| Question | Answer |
|---|---|
| a group of statements that is executed when it is called from some point of the program | function |
| a self contained block of code with a specific purpose | function |
| It has a name that is used to identify and call it for execution | function |
| subprogram that acts on data and often returns a value | function |
| • easier to maintain, • update and • debug than one very long program | advantages of function |
| By programming in a modular (functional) fashion, several programmers can work independently on separate functions which can be assembled at a later date to create the entire project | True |
| One function that every C++ program possesses: __________ | int main() |
| The program that calls a function is often referred to as the ___________ | calling program |
| programmed routine that has its parameters set by the user of the system | user defined function |
| functions that perform specific tasks within a larger system, such as a database or spreadsheet program | User defined functions |
| return_type function_name(parameter_list ) { local_definitions; function_implementation; } | e standard form of declaration of a function |
| If the function returns a value then the type of that value must be specified in _____________ | return_type |
| If the function does not return a value then the return_type must be __________ | void |
| follows the same rules of composition as identifiers. | function_name |
| lists the formal parameters of the function together with their types | parameter_list |
| definitions of variables that are used in the function_implementation. These variables have no meaning outside the function | local_definitions |
| consists of C++ executable statements that implement the effect of the function | function_implementation |
| main parts of the function: The function ________ and the function __________ | header and body |
| int sum(int x, int y) | function header |
| •The name of the function i.e. sum •The parameters of the function enclosed in paranthesis •The return value type i.e. int | three main parts |
| written in { } | body of the function |
| It provides the basic information about a function which tells the compiler that the function is used correctly or not | function prototype |
| It contains the same information as the function header contains | function prototype |
| It can be used to check the calls to the function for the proper number of parameters and the correct types of parameters | function prototype |
| The only difference between the header and the prototype is the _______ | semicolon ;. |
| function that can be made to return a single value to the calling program is referred to as __________ | non-void function. |
| function that is written to perform specific task and return multiple values to calling program | void functions |
| variables/values used within the function call | Actual arguments |
| variables used within the function header that receives the copy of the actual argument values | formal parameters |
| The number of actual arguments must be the same as the number of formal parameters | True |
| The correspondence between actual and formal parameter is __________ basis according to the respective orders | one-to-one |
| This means that when calling a function with parameters, what we have passed to the function were copies of their values but never the variables themselves | pass by value |
| In some cases where you need to manipulate from inside a function the value of an external variable we can use arguments __________ | passed by reference |
| In the declaration, the type of each parameter was followed by an ___________ to specify that their corresponding arguments are to be passed by reference instead of by value | ampersand sign (&) |
| A function that calls itself is known as a ____________ | recursive function |
| function call in which the function being called is the same as the one making the call. | Recursive call |
| programming technique in which procedures and functions call themselves | Recursion |
| The case for which the solution can be stated non-recursively The case for which the answer is explicitly known | Base case |
| The case for which the solution is expressed in smaller version of itself. Also known as recursive case. | General Case |
| Also known as recursive case. | General Case |
| In recursion, it is essential for a function to call itself, otherwise recursion will not take place | True |
| Only user define function can be involved in recursion. | True |
| To stop the recursive function it is necessary to base the recursion on test condition and proper terminating statement such as exit() or return must be written using if() statement. | True |
| When a recursive function is executed, the recursive calls are not implemented instantly. All the recursive calls are pushed onto the stack until the terminating condition is not detected, the recursive calls stored in the stack are popped and execu | True |
| During recursion, at each recursive call new memory is allocated to all the local variables of the recursive functions with the same name. | True |
| • It makes our code shorter and cleaner. • Complex code and nested for loops are avoided here. • Recursion is required in problems concerning data structures and | Advantages of C++ Recursion |
| It takes a lot of stack space compared to an iterative program. • It uses more processor time. • It can be more difficult to debug compared to an equivalent iterative program. advanced algorithms, such as Graph and Tree Traversal. | Disadvantages of C++ Recursion |