Java Program To Find Quotient And Remainder Of Number

Write Java program to find quotient and remainder of the given number

// WAP to find quotient and remainder of the given number

import java.util.Scanner;
public class Divisor
{
    public static void main(String[] args) 
    {
        int dividend,divisor,quotient,remainder;
        
        Scanner sc = new Scanner(System.in);

        System.out.println("Enter the dividend number :-->");
        dividend = sc.nextInt();

        System.out.println("Enter the divisor number :-->");
        divisor = sc.nextInt();

        quotient = dividend / divisor;
        remainder = dividend % divisor;
        
        System.out.println("Quotient :-->"+quotient);
        System.out.println("remainder :-->"+remainder);

        sc.close(); // prevent memory leakage

    }
} 

Output:


<< Previous | Next >>


Leave a Reply

Your email address will not be published.