You need to pass an array for the quotient and remainder into the divide function. Than you can read the values after the function returns.
#include<stdio.h>
void div(int* a, int* b, float* quotient, int* remainder, int count) {
for (int i = 0; i < count; i++)
{
quotient[i] = a[i] / (double)b[i];
remainder[i] = a[i] % b[i];
}
}
int main() {
int a[] = { 3,6,9,12,16,18 }, b[] = { 2,3,3,4,4,4 };
#define LENGTH (sizeof(a) / sizeof(int))
float quotient[LENGTH];
int remainder[LENGTH];
div(a, b, quotient, remainder, LENGTH);
for (int i = 0; i < LENGTH; i++)
{
printf("Quotient is: %.1f\nRemainder is: %d\n", quotient[i], remainder[i]);
}
return 0;
}
CLICK HERE to find out more related problems solutions.