-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFind Remainder
46 lines (40 loc) · 902 Bytes
/
Find Remainder
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Problem
Write a program to find the remainder when an integer A is divided by an integer B.
Input
The first line contains an integer T, the total number of test cases. Then T lines follow, each line contains two Integers A and B.
Output
For each test case, find the remainder when A is divided by B, and display it in a new line.
Constraints
1 ≤ T ≤ 1000
1 ≤ A,B ≤ 10000
Sample 1:
Input
Output
3
1 2
100 200
40 15
1
100
10
answer:
// We have populated the solutions for the 10 easiest problems for your support.
// Click on the SUBMIT button to make a submission to this problem.
#include<iostream>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int a,b,c,d;
cin>>a>>b;
if (a>=b){
c=a%b;
cout<<"\n"<<c;
}
else
{d=a%b;
cout<<"\n"<<d;}
}
return 0;
}