/* * Program to illustrate pass by reference / pointers. * * (It asks the user for two numbers, divides them, and * prints the quotient and remainder.) */ #include void divide(int input1, int input2, int * quotient, int * remainder) { *quotient = input1 / input2; *remainder = input1 % input2; } int main(void) { int input1; int input2; int q, r; printf("enter two numbers:\n"); if (scanf("%d %d", &input1, &input2) != 1) { printf("error -- not numbers\n"); exit(1); } divide(input1, input2, &q, &r); printf("dividing %d by %d gives quotient %d and remainder %d\n", input1, input2, q, r); return 0; }