Find Remainder – CodeChef Solution

Hello, Coders!!

Today we will be solving Find Remainder CodeChef Problem in Python, Java and C++ whose code is FLOW002.

find-remainder-codechef-solution-codebrosindia

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

Example

Input

3 
1 2
100 200
40 15

Output

1
100
10

Solution – Find Remainder CodeChef Solution

Python

#Solution Provided by CodingBroz
N = int(input())
while N > 0:
    a, b = map(int, input().split())
    Remainder = a % b 
    print(Remainder)
    N = N - 1

Java

import java.util.*;
import java.io.*;

public class Main{

public static void main(String[] args) throws IOException{
 // TODO Auto-generated method stub
 Scanner sc = new Scanner(System.in);
 int t = sc.nextInt();
 for(int i=0 ; i<t ; i++)
 {
 int a = sc.nextInt();
 int b = sc.nextInt();
 
 System.out.println(a%b);
 
 }
 }
 
}

Find Remainder CodeChef Solution

C++

#include <iostream>
using namespace std;

int main() {
    int a,b,t,r;
    cin>>t;
    for(int i=0;i<t;i++)
    {
        cin>>a>>b;
        r=a%b;
         cout<<r<<endl;
    }
   
 return 0;
}
Find Remainder CodeChef Solution

Disclaimer: The above Problem (Find Remainder : FLOW002) is generated by CodeChef but the Solution is provided by CodingBroz. This tutorial is only for Educational and Learning Purposes.

Broz Who Code

CodingBroz

Leave a Comment

Your email address will not be published. Required fields are marked *