Find Remainder Codechef Solution

Hello Programmers In this post, you will know how to solve the Find Remainder Codechef Solution.

Find Remainder Codechef Solution
Find Remainder Codechef Solution

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.

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

Find Remainder CodeChef Solutions in Python

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

Find Remainder CodeChef Solutions in CPP

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t,a,b;
    cin>>t;
    while(t--)
    {
        cin>>a>>b;
        cout<<a%b<<endl;
    }
    return 0;
}

Find Remainder CodeChef Solutions in JAVA

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for (int tc = 0; tc < T; tc++) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			System.out.println(solve(A, B));
		}
		sc.close();
	}
	static int solve(int A, int B) {
		return A % B;
	}
}

Disclaimer: The above Problem (Find Remainder) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purpose.

Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.

Next: Add Two Numbers Codechef Solution

Leave a Reply

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