Functions
A function has a return type, a name, and a list of parameters. Parameters in C are always passed by value — the function gets its own copy of each argument, so changes inside the function don't affect the caller's variable (passing a pointer, covered two lessons from now, is how you get around that).
main.c
Try it yourself →#include <stdio.h>
int multiply(int a, int b) {
return a * b;
}
int main() {
printf("%d\n", multiply(6, 7));
return 0;
}Output
42
Next: arrays — C's fixed-size, no-bounds-checking collection type.
Practice exercise
Write a function multiply(int a, int b) that returns a * b, then print multiply(6, 7).