Algorithm


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

  •  T  1000
  •  A,B  10000

Sample 1:

Input
 
Output
 
3 
1 2
100 200
40 15
1
100
10

Code Examples

#1 Code Example with C Programming

Code - C Programming

#include<stdio.h>
int main()
{
    int n,r,num;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d %d",&num,&r);
        printf("%d\n",num%r);
    }
}  
Copy The Code & Try With Live Editor

Input

x
+
cmd
3
1 2
100 200
40 15

Output

x
+
cmd
1
100
10
Advertisements

Demonstration


CodeChef solution FLOW002  - Find Remainder Codechef solution in C,C++

Previous
CodeChef solution HS08TEST ATM - HS08TEST ATM solution in C,C++
Next
CodeChef solution XPIRY - Expiring Bread Codechef solution in C,C++