Python/C/C++/JAVA

Basic Practice Programs with Code and Concept

By D.S

Find Quotient and Remainder

This program demonstrates how to find the quotient and remainder of a division operation between two numbers. It prompts the user to input two numbers and then calculates and displays their quotient and remainder.

(a.) C Code

#include <stdio.h>

    int main() {
        int dividend = 10, divisor = 3;
        int quotient, remainder;

        quotient = dividend / divisor;
        remainder = dividend % divisor;

        printf("Quotient: %d
", quotient);
        printf("Remainder: %d
", remainder);

        return 0;
    }
Output:-
Quotient: 3
Remainder: 1

(b.) C++ Code

#include <iostream>

    using namespace std;

    int main() {
        int dividend = 10, divisor = 3;
        int quotient, remainder;

        quotient = dividend / divisor;
        remainder = dividend % divisor;

        cout << "Quotient: " << quotient << endl;
        cout << "Remainder: " << remainder << endl;

        return 0;
    }
Output:-
Quotient: 3
Remainder: 1

(c.) Python Code

dividend = 10
    divisor = 3

    quotient = dividend // divisor
    remainder = dividend % divisor

    print("Quotient:", quotient)
    print("Remainder:", remainder)
Output:-
Quotient: 3
Remainder: 1

(d.) Java Code

public class QuotientAndRemainder {
        public static void main(String[] args) {
            int dividend = 10, divisor = 3;
            int quotient, remainder;

            quotient = dividend / divisor;
            remainder = dividend % divisor;

            System.out.println("Quotient: " + quotient);
            System.out.println("Remainder: " + remainder);
        }
    }
Output:-
Quotient: 3
Remainder: 1