| functions/functions-input-4.c - Funktionen f ændrer på værdierne af de to lokale variable. | Lektion 6 - slide 8 : 21 Program 9 |
#include <stdio.h>
/* Input: We pass the values of two variables to f, and use these for initialization of two local variables.
We change the values of the local variables in f. */
void f(int fp1, int fp2){
int a = fp1, b = fp2; /* We initialize local varibale from formal parameters */
a += 1; b += 2; /* OK to assign to local variabels */
printf("a + b = %d + %d = %d\n", a, b, a + b);
}
int main(void) {
int i = 3,
j = 4;
f(i, j);
printf("i + j = %d + %d = %d\n", i, j, i + j);
return 0;
}