#### C++ Problem solving

## Read the description of find reminder problem

In this find reminder simple problem we have to find the reminder dividing A by B. The number A and B is given by the user. We have to store the given number into two variables and the calculate the reminder of A/B.

This is a very simple problem and if you have completed our C++ programming section, then it will be very simple to solve for you. However, this problem is taken from CodeChef for practice and learning purpose of our readers. In this article we will solve the problem and discuss how the program works. So, let’s go ahead.

## Solution to find reminder problem

We will take the number of test case from the user and then take two input for every test case. We will store that two input in variable a and b. The we will find the reminder using a % b and print that reminder.

Consider, the user gives two integer 10 and 3. Then we have to print the reminder of dividing 10 by 3. We know the reminder will be 1 for these two inputs.

**10Â %Â 3Â =Â 1**;

Now, we will see the source code to implement this logic for printing the reminder.

```
// solving find reminder problem using C++
#include<iostream>
using namespace std;
int main(){
int t, rem = 0;
cin >> t;
for(int i = 0; i < t; i++){
int a, b;
cin >> a >> b;
rem = a % b;
cout << rem << endl;
rem = 0;
}
}
```

The output of this program will be as like as bellow.

```
3
1 2
1
100 200
100
40 15
10
```

First line contains the user input which is the test case for this problem. Then each test case takes two input a and b. Then the third line is the output for the input of second line.

**Previous page**:Â **ATM program**

**Next page**:Â **Sum of digits**

**Recommended for you**: