A Function Calls tell the name of the functions to use. Can be use like any expression. Is used in a statement where the returned value makes sense. For example:
side = sqrt(area);
To include the math library containing sqrt(); we use #include <cmath>
Other Predefined Functions are:
A Type Cast produces a value of one type from another type. For example: static_cast<double>(total_candy) produces a double representing the integer value of total_candy.
A Function definition describe how the function does its task. Can appear before or after the function is called.
//code to make the function work
A Function declaration show how the function is called. Must appear in the code before the function is called. Tell the return type name of function.
Function_name(Parameter_list);
The Return Statement ends the function call and returns the value calculated by the function.
return expression;
- expression performs the calculation or expression is a variable containing the calculated value. For example:
- return subtotal + subtotal * TAX_RATE;
A Pseudocode is a mixture of C++ & English. They simplifies algorithm design by allowing you to ignore the specific syntax of the programming language as you work out the details of the algorithm.
Global variable: rarely used when move than one function must use a common variable.
No hay comentarios.:
Publicar un comentario