Sunday, 11 March 2018

Find Remainder

  1. Find Remainder


    All submissions for this problem are available.
    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

    Example

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

    Solutions

    #include <stdio.h>
  2.  
  3. int main() {
  4. // Read the number of test cases.
  5. int T;
  6. scanf("%d", &T);
  7. while (T--) {
  8. // Read the input a, b
  9. int a, b;
  10. scanf("%d %d", &a, &b);
  11.  
  12. // Compute the ans.
  13. // Complete this line.
  14. int ans =a%b;
  15. printf("%d\n", ans);
  16. }
  17.  
  18. return 0;
  19. }

No comments:

Post a Comment

Reverse The Number

Reverse The Number All submissions for this problem are available. If an Integer   N , write a program to reverse the given number. ...