Object
Write a program that reads two integers, divides one integer by another and returns the quotient and the remainder in function main.
Algorithm
- Declare a function void divide(int *quo, int *rem, int x, int y) that accepts two integer pointers and two integers as arguments and returns no value.
The Function main - Declare integer variables a, b, quo and rem.
- Read a and b.
- Call the function divide(&quo, &rem, a, b) considering a and b and addresses of quo and rem as actual arguments.
- Write quo and rem.
- Exit.
Defining the Function void divide(int *quo, int *rem, int x, int y)
where *quo, *rem and x and y are the formal arguments - *quo = x/y.
- *rem = x%y.
- Exit.
Flowchart

C++ Source Code
// program 105
#include<iostream>
using namespace std;
void divide(int *quo, int *rem, int x, int y);
int main()
{
int a, b, quo, rem;
cout << "Enter any two numbers = ";
cin >> a >> b;
divide(&quo, &rem, a, b);
cout << "\nThe Quotient of " << a << "/" << b << " is: " << quo << endl;
cout << "The Remainder of " << a << "/" << b << " is: " << rem << endl;
return 0;
}
void divide(int *quo, int *rem, int x, int y)
{
*quo = x / y;
*rem = x % y;
}
C Source Code
/*program 105*/
#include<stdio.h>
void divide(int *, int *, int, int);
int main()
{
int a, b, quo, rem;
printf("\nEnter any two numbers = ");
scanf("%d%d", &a, &b);
divide(&quo, &rem, a, b);
printf("\nThe Quotient of %d/%d is: %d", a, b, quo);
printf("\nThe Remainder of %d/%d is: %d", a, b, rem);
return 0;
}
void divide(int *quo, int *rem, int x, int y)
{
*quo = x / y;
*rem = x % y;
}
Output
Enter any two numbers = 34 6
The Quotient of 34/6 is: 5
The Remainder of 34/6 is: 4
