Foundations
Functions
A function names reusable work and can return a computed value.
Functions
functions.c
#include <stdio.h>
int addTax(int price) {
return price + price / 10;
}
int main(void) {
int price = ;
int total = addTax(price);
printf("total=%d\n", total);
return 0;
}
#include <stdio.h>
int addTax(int price) {
return price + price / 10;
}
int main(void) {
int price = ;
int total = addTax(price);
printf("total=%d\n", total);
return 0;
}
#include <stdio.h>
int addTax(int price) {
return price + price / 10;
}
int main(void) {
int price = ;
int total = addTax(price);
printf("total=%d\n", total);
return 0;
}
parameter
A parameter receives the value passed by the caller.
return
`return` sends a value back to the caller.