Computer Science, asked by shakuntalagupta015, 4 months ago

IV. Write a program in java to print the quotient and remainder of the integer 187 by integer 13.​

Answers

Answered by allysia
1

Program:

public class oh {

public static void main(String[] args) {

 int i=187;

 int j=13;

 int quo=i/j;

 int rem=i%j;

 System.out.print("The quotient will be: " + quo + "\nThe remainder will be: "+rem );

}

}

Explanation:

int (23/7) will return the part before decimal only which is the quotient  and % (modulus operator) returns the remainder part.

Attachments:
Answered by anindyaadhikari13
5

Required Answer:-

Question:

  • Write a program in Java to print the quotient and remainder of the integer 187 by integer 13.

Solution:

Here is the code.

  1. public class JavaBrainly {
  2. public static void main(String[] args){
  3. int a, b, q, r; // Declaring variables.
  4. a=187;
  5. b=13;
  6. q=a/b;
  7. r=a%b;
  8. System.out.println("Quotient: "+q);
  9. System.out.println("Remainder: "+r);
  10. }
  11. }

Explanation:

  • / operator is also called division operator. Integer division returns the quotient that we obtain after dividing. Dividing 187 by 13 gives 14 as quotient and 5 as remainder. % operator, also known as modulo operator is used for finding out the remainder.
  • Note: If the data types of the variables a, b are other that int data type, then the output will be different.

Output is attached for verification.

Variable Description:

  • a(int):- Stores 87 here.
  • b(int):- Stores 13 here.
  • q(int):- Calculate quotient and store here.
  • r(int):- Calculate remainder and store here.
Attachments:
Similar questions