| functions/functions-input-3.c - Funktionen f ændrer på værdierne af de to formelle parametre. | Lektion 6 - slide 8 : 21 Program 7 |
#include <stdio.h>
/* Input: We pass the values of two variables to f.
We change the values of the formal parameters in f. */
void f(int fp1, int fp2){
fp1 += 1; fp2 += 2; /* Bad to alter the values of formal parameters */
printf("fp1 + fp2 = %d + %d = %d\n", fp1, fp2, fp1 + fp2);
}
int main(void) {
int i = 3,
j = 4;
f(i, j);
printf("i + j = %d + %d = %d\n", i, j, i + j);
return 0;
}