Tuesday, 21 February 2017

Find Remainder

QUESTION DESCRIPTION :


Write a program to find the remainder when two given numbers are divided.

Input

The first line contains an integer T, total number of test cases. Then follow T lines, each line contains two Integers A and B.

Output

Find remainder when A is divided by B.

Constraints

1 ? T ? 1000
1 ? A,B ? 10000


TEST CASE 1

INPUT

3
1 2
100 200
10 40

OUTPUT

Remainder is 1
Remainder is 100
Remainder is 10


EXPLANATION :

This problem is similar to Modulo Operations , but you have to do it for multiple inputs , the number of inputs is given by the first integer received from the user.


QUESTION ISSUES :

The constraints given contain " ? " but it should be either " < " or " <= "


ALGORITHM:

  • Input the number of test cases from the user ( t )
  • Run a loop till t , to get all input cases
  • Input the two numbers from the user ( a,b )
  • Compute the remainder using modulo operator ( a%b )
  • Print the result
  • Redo this for all other test cases 

SOLUTION : (Please use this as reference only)

CODE

No comments:

Post a Comment