Javascript program to enter two numbers and perform all arithmetic operations
ADVERTISEMENTS
Javascript program to enter two numbers and perform all arithmetic operations. There are you will learn how to perform all arithmetic operations in javascript language.
Let us understand this through Javascript program:
<script type="text/javascript">
var p, q;
var sum, sub, mul, div, mod;
p = 8;
q = 6;
/* Perform all arithmetic operations */
sum = p + q;
sub = p - q;
mul = p * q;
div = p / q;
mod = p % q;
/* Print result of all arithmetic operations */
document.write("SUM " + p + " + " + q + " = " + sum + "<br />");
document.write("DIFFERENCE " + p + " - " + q + " = " + sub + "<br />");
document.write("PRODUCT " + p + " * " + q + " = " + mul + "<br />");
document.write("QUOTIENT " + p + " / " + q + " = " + div + "<br />");
document.write("MODULUS " + p + " % " + q + " = " + mod);
</script>
Output Screen:
SUM 8 + 6 = 14
DIFFERENCE 8 - 6 = 2
PRODUCT 8 * 6 = 48
QUOTIENT 8 / 6 = 1.3333333333333333
MODULUS 8 % 6 = 2