Program to find quotient and remainder of number

Program to find quotient and remainder of number

  • Write a program to find quotient and remainder of number in C
  • Write a program to find quotient and remainder of number in C++
  • Write a program to find quotient and remainder of number in Python
  • Write a program to find quotient and remainder of number in PHP
  • Write a program to find quotient and remainder of number in Java
  • Write a program to find quotient and remainder of number in Java Script
  • Write a program to find quotient and remainder of number in C#

Explanation:

In arithmetic, when dividing one number by another, we get two results:

  1. Quotient: The integer result of the division (ignoring the remainder).
  2. Remainder: The leftover portion after division.

If aaa is divided by bbb:

  • Quotient: quotient = floor(a/b)
  • Remainder: remainder = a mod b

For example:

  • Dividing 10 by 3:
    • Quotient: 10/3 = 3 (integer division)
    • Remainder: 10 mod  3 = 1

Program to find quotient and remainder of number

#include <stdio.h>

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

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

    return 0;
}

#include <iostream>

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

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

    return 0;
}

dividend = 10
divisor = 3

quotient = dividend // divisor
remainder = dividend % divisor

print(f"Quotient: {quotient}")
print(f"Remainder: {remainder}")

<?php
$dividend = 10;
$divisor = 3;

$quotient = intdiv($dividend, $divisor);  // For quotient
$remainder = $dividend % $divisor;        // For remainder

echo "Quotient: $quotient\n";
echo "Remainder: $remainder\n";
?>

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

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

        System.out.println("Quotient: " + quotient);
        System.out.println("Remainder: " + remainder);
    }
}

let dividend = 10;
let divisor = 3;

let quotient = Math.floor(dividend / divisor);
let remainder = dividend % divisor;

console.log(`Quotient: ${quotient}`);
console.log(`Remainder: ${remainder}`);

using System;

class Program {
    static void Main() {
        int dividend = 10, divisor = 3;

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

        Console.WriteLine($"Quotient: {quotient}");
        Console.WriteLine($"Remainder: {remainder}");
    }
}

List of All Programs