int addmult(int ii, int jj){
int kk, ll;
kk = ii + jj;
ll = ii * jj;
return (kk, ll);
}
void main(void){
int i=3, j=4, k, l;
k = addmult(i, j);
l = addmult(i, j);
printf("%d, %d\n", k, l);
}
I thought that it wasn't possible to return two variables from a function. How does the compiler know to print ll
instead of kk
? I know that in the function ii=3
and jj=4
, k=7
and l=12
, but then it goes on to return two variables. Could someone please elaborate on why it ends up printing:
12, 12