Functions in C
A fragment of code that accepts zero of more argument values, produces a result value and has zero or more side effects.
Arguments
By default arguments are passed by value:
int main (void) {
putInFridge(eggs)
return 0;
}
This means that if the variable changes in the function, the change is not made outide the function.
Library Functions
math.h
sin(x)
- (Radians)cos(x)
- (Radians)tan(x)
- (Radians)atan(x)
atan2(y,x)
exp(x)
- ($e^x$)log(x)
- ($\log_e x$)log10(x)
- ($log_{10} x$)sqrt(x)
- ($x \geq 0$)pow(x, y)
($x^y$)
string.h
strcpy()
strcat()
strcmp()
strlen()
stdio.h
printf()
fprintf()
scanf()
sscanf()
Function Definition Syntax
returnType functionName(type1 parameter1, ...) {
// function body
}