Functions Flashcards
What is a function in C?
A named, independent section of C code that performs a specific task and optionally returns a value to the calling statement.
What are the two types of functions in C?
- Standard Library functions (built-in)
- User-defined functions (custom)
What is the syntax for creating a function in C?
[data_type] function_name([data_type param,…]){ data_type local_variable; … program_statement; … [return expression;]}
What does the function prototype declaration tell the compiler?
- Its data type
- Its name
- The argument it takes
- Who can call it
What keyword is used to return a value from a function?
return
What is the default data type of a function if omitted?
int
What does ‘call by value’ mean?
Each argument passed to a function is evaluated, and its value is passed into the function.
What is ‘call by reference’?
A method where a reference to the variable (memory address) is passed into the function instead of its value.
What are non-returning functions without parameters?
Functions declared as void that do not return a value and do not take any parameters.
What is a returning function with parameters?
A function that returns a value and accepts parameters.
Fill in the blank: The function’s _______ is a unique identifier used to call it.
name
What is the purpose of the standard library functions in C?
They are built-in functions defined in header files.
True or False: A function can be called from within another function.
True
What is the role of the return statement in a function?
It indicates that the function is to return the value of the expression back to the calling function.
What must the function prototype declaration reflect?
The data type of the return value.
What does the function ‘double_it’ do in the provided example?
It doubles the input value a specified number of times and prints the result.