Midterms Flashcards
group of statements that together perform a task
function
tells the compiler about a function’s name, return type, and parameters
function
already present inside the header file, included at the beginning of a program
library functions
we have tow write a body of a function and call the function when required
user-defined functions
why we need functions in c++
- errors are easy to track
- reduces size of code
-replacing duplicate statements with function calls - reusability of code
- improves code readability
various forms of the main method
main()
main (void)
void main()
void main (void)
int main (int argc, charargv[])
void main(int argc, charargv[])
main method that does not return any value should have the return type?
void
main method that returns a value should have the return type?
int
also called function prototype. specifies the name of a function to be used in the program like a variable declaration
function declaration
syntax of function declaration
return_data_type function_name (data type arguments);
means writing the body of a function, consisting of statements that perform specific tasks
function definition
invoking a function also means
calling a function/function call
two methods to call a function
- call by value
- call by reference
copies the actual value of an argument into the formal parameter of the function
call by value
function that is expanded in line when it is invoked thus saving time
inline function