Program to find Quotient and Remainder

Description

The quotient is evaluated using / (the division operator), and stored in quotient.
The remainder is evaluated using % (the modulo operator) and stored in remainder.

C/C++

/* C Program to find Quotient and Remainder */
//Save it as AreaCircle.c

#include<stdio.h>
int main(){

    int firstNumber, secondNumber, quotient, remainder;

    printf("Enter the first number : ");
    scanf("%d",&firstNumber);

    printf("Enter the second number : ");
    scanf("%d",&secondNumber);

    quotient = firstNumber/secondNumber;

    remainder = firstNumber%secondNumber;

    printf("The quotient after division : %d",quotient);
    printf("\nThe remainder after division : %d",remainder);

    return 0;
}
Input:
Enter the first number : 10
Enter the second number : 3

Output:
The quotient after division : 3
The remainder after division : 1

Java

/* Java Program to find Quotient and Remainder */
//Save it as AreaCircle.java

import java.io.*;
import java.util.Scanner;

public class QuotientRemainder {

    public static void main(String[] args) {

            Scanner scanner = new Scanner(System.in);
        
            int firstNumber, secondNumber, quotient, remainder;

        System.out.println("Enter the first number : ");
        firstNumber = scanner.nextInt();

        System.out.println("Enter the second number : ");
        secondNumber = scanner.nextInt();

        quotient = firstNumber/secondNumber;

        remainder = firstNumber%secondNumber;

        System.out.println("The quotient after division : "+quotient);
        System.out.println("The remainder after division : "+remainder);
    }
}
Input:
Enter the first number : 
10
Enter the second number : 
3

Output:
The quotient after division : 3
The remainder after division : 1

Related Programs

1) Add Two Numbers
2) Program to subtract two numbers
3) Program to multiply two numbers
4) Program to divide two numbers
5) Program to find modulus of two numbers
6) Program to calculate power of a number
7) Program to calculate Permutation And Combination
8) Program to find simple interest
9) Program to calculate Gross Salary
10) Program to calculate percentage mark of student
Share Me

Leave a Reply