Java Program to Compute Quotient and Remainder

Find quotient and remainder

Java program to compute quotient and remainder has been shown here. Find here the algorithm, pseudocode and time complexity of the program. The flowchart of the problem can be found here.






1. Java Program & output to Compute Quotient and Remainder

Code has been copied
/********************************************
        Alphabetacoder.com
Java program to compute quotient and remainder
********************************************/
public class QuotientRemainder{
    public static void main(String args[]){
        //initialize two variables
        int a=17,b=5;
        int q,r;
        
        //find the quotient
        q=a/b;
        //find the remainder
        r=a%b;
        
        System.out.println("When "+a+" is divided by "+b+", quotient is "+q+" and remainder is "+r+".");
    }
}

Output


When 17 is divided by 5, quotient is 3 and remainder is 2.