Computer Science, asked by BubblySnowflake5067, 3 months ago

Write a program in JAVASCRIPT to create a calculator for addition, subtraction, multiplication, and division of 2 numbers.

Answers

Answered by MOHDAFAN
3

Answer:

function multiplyBy()

{

num1 = document.getElementById("firstNumber").value;

num2 = document.getElementById("secondNumber").value;

document.getElementById("result").innerHTML = num1 * num2;

}

function divideBy()

{

num1 = document.getElementById("firstNumber").value;

num2 = document.getElementById("secondNumber").value;

document.getElementById("result").innerHTML = num1 / num2;

}

Explanation:

PLEASE MARK ME AS BRAINLIST AND THANKS ME AND FOLLOWING ME

Answered by Reevan404
1

1. Addition

const num1 = 5;

const num2 = 3;

// add two numbers

const sum = num1 + num2;

// display the sum

console.log('The sum of ' + num1 + ' and ' + num2 + ' is: ' + sum);

2. Multiplication

function multiplyBy()

{

       num1 = document.getElementById("firstNumber").value;

       num2 = document.getElementById("secondNumber").value;

       document.getElementById("result").innerHTML = num1 * num2;

}

function divideBy()  

{  

       num1 = document.getElementById("firstNumber").value;

       num2 = document.getElementById("secondNumber").value;

document.getElementById("result").innerHTML = num1 / num2;

}

3. Subtraction

var x = 5;

var y = 2;

var z = x - y;

4. Dividing

var x = 5;

var y = 2;

var z = x / y;

Similar questions