IV. Write a program in java to print the quotient and remainder of the integer 187 by integer 13.
Answers
Answered by
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
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.
- public class JavaBrainly {
- public static void main(String[] args){
- int a, b, q, r; // Declaring variables.
- a=187;
- b=13;
- q=a/b;
- r=a%b;
- System.out.println("Quotient: "+q);
- System.out.println("Remainder: "+r);
- }
- }
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