Pass return value through function parameter
#include <stdio.h>
#include <stdlib.h>
void mean(int a,int b, int *ptr_to_answer) {
*ptr_to_answer = (a + b)/2;
}
int main() {
int i, j;
int answer;
i = 6;
j = 9;
mean(i,j, &answer); /* passing a pointer to 'answer' */
printf(" The mean of %d and %d = %d\n", i, j, answer);
}
Related examples in the same category