math-unlimited

Arithmetic Operation

Arithmetic operations are fundamental mathematical processes that involve manipulating numbers to perform calculations. These operations form the basis of many mathematical computations and are used in various fields such as science, engineering, economics, and everyday problem-solving. The primary arithmetic operations include addition, subtraction, multiplication, and division, along with more advanced operations like exponentiation and modulus.

Operand & Operator

Operand is the value or data on which an operation is performed. In mathematical expressions or programming, operands can be numbers, variables, or any data that is used in conjunction with an operator to produce a result. Operands act as inputs to operators. Operator is a symbol or keyword that specifies the type of operation to be performed between one or more operands. Operators can represent mathematical operations (e.g., addition, subtraction), logical comparisons (e.g., greater than, equal to), or other functions.

  1. Addition (+) is the process of combining two or more numbers to get a total or sum. The numbers being added are called addends, and the result is the sum.
  2. Subtraction (-) is the process of finding the difference between two numbers. The number from which another number is subtracted is called the minuend, and the number being subtracted is the subtrahend. The result is the difference.
  3. Multiplication (X or *) is the process of combining equal groups to find the total. The numbers being multiplied are called factors, and the result is the product.
  4. Division (/) is the process of splitting a number into equal parts. The number being divided is the dividend, the number by which it is divided is the divisor, and the result is the quotient.
  5. Modulus (%) is the operation of finding the remainder when one number is divided by another.

Arithmetic Operation Concept

Arithmetic Concept

Operand Operator Operand = Result

Syntax Example: A + B = C

Input/Operand: A, B

Operator: +

Output: C

Mathematical Example:

Addition: 10 + 20 = 30

Subtraction: 20 - 10 = 10

Multiplication: 10 * 20 = 200

Division: 20 / 10 = 2

Modulo: 20 % 10 = 0

React.JS Example

0

JavaScript Code

JavaScript Code

import {arithmetic} from 'math-unlimited';

console.log(arithmetic(10, 20, "Addition")); // 30

console.log(arithmetic(20, 10, "Subtraction")); // 10

console.log(arithmetic(10, 20, "Multiplication")); // 200

console.log(arithmetic(20, 10, "Division")); // 2

console.log(arithmetic(20, 10, "Modulo")); // 0

console.log(arithmetic(150, 70, "addition")); // 220

console.log(arithmetic(80, 120, "subtraction")); // -40

console.log(arithmetic(140, 20, "multiplication")); // 2800

console.log(arithmetic(250, 40, "division")); // 6.25

console.log(arithmetic(230, 70, "modulo")); // 20

React.JS Code

React.JS Code

'use client';
import { useState } from "react";
import { arithmetic } from "math-unlimited";
import "../styles/arithmetic.css";
export default function ArithmeticDemo () {
    const [Res, setRes] = useState(0);
    const HandleOperation = (e) => {
        e.preventDefault();
        const formData = new FormData(e.target);
        const Obj = Object.fromEntries(formData.entries());
        console.log(Obj);
        setRes(arithmetic(parseInt(Obj.IP1), parseInt(Obj.IP2), Obj.OPERATOR));
        e.target.reset();
        setTimeout(() => {
            setRes(0);
        }, 5000);
    }
    return (
        <>
            <section className="ARTH-DEMO-SEC">
                <form onSubmit={HandleOperation}>
                    <input type='text' placeholder='Enter Input Value1' name='IP1' />
                    <input type='text' placeholder='Enter Input Value2' name='IP2' />
                    <select name="OPERATOR">
                        <option value={'ADDITION'}>Addition</option>
                        <option value={'SUBTRACTION'}>Subtraction</option>
                        <option value={'MULTIPLICATION'}>Multiplication</option>
                        <option value={'DIVISION'}>Division</option>
                        <option value={'MODULO'}>Modulo</option>
                    </select>
                    <input type='submit' value='Calculate' />
                </form>
                <p>{Res}</p>
            </section>
        </>
    );
}