-->

Hello,This is me!

ITEngineer8995

Professional Coder Coding is my passion

Saturday, May 23, 2020

Java Program To Find Quotient and Remainder

  • May 23, 2020
  • by

Java Program To Find Quotient and Remainder

In this Java Program, we find the Quotient and Remainder of the given two numbers.

The Quotient is the quantity produced by the division of the two numbers while the Remainder is the integer left over after dividing one integer by another.
             
E.g.                  7       👈 Quotient 
                     ___
                  2 | 15
                   -  14
                    ____
                         1       👈 Remainder
                               

In the above example, we take two numbers num 1 = 15 and num 2 = 2, where num 1 is the dividend and num 2 is the divisor.  When num 1 is divided by the num 2 we get the quotient as 7 and remainder as 1.

Logic : quotient = num 1 / num 2
          : remainder = num 1 % num 2

Step 1 : Create variables num1 and num2 and store the numbers 15 in num1 and 2 in num2.

Step 2 : Create variable quotient and apply the logic and store the result into the variable quotient.

Step 3 : Create variable remainder and apply the logic and store the result into the variable remainder.

Step 4 : Display the result by using the System.out.print.

Program :

public class QuotientRemainder 
    {
        public static void main(String[] args)
        {
            int num1 = 15, num2 = 2;
            int quotient = num1 / num2;
            int remainder = num1 % num2;
            System.out.println("Quotient is:" +quotient);
            System.out.println("Remainder is:" +remainder);
        }
    
}

Output:

Quotient is : 7
Remainder is : 1

For execution of the same do visit my YouTube Channel:

A blog full of codes of various languages like Java, .net, C, C++ etc with their outputs and some other IT stuff.

0 comments:

Post a Comment

ITEngineer8995
India

SEND ME A MESSAGE

Search This Blog

Powered by Blogger.

Pages