In this tutorial, we will discuss the title of the JavaScript Program to multiply of Two Numbers
In this topic, we are going to learn how to write a program to multiply of two numbers in the JavaScript programming language
Program 1
Here, We use the multiplication(*) operator to find the product of the given two numbers.
The program calculates the product of the two numbers 7 and 5 , and the output is displayed here.
// JavaScript program to multiplication of two numbers const f_Num=7; //declare and initaiize variable for first num const l_Num=5; //declare and initaiize variable for second num //calculate multiplication of given two numbers const mul=f_Num*l_Num; //display the multiplication of two numbers console.log('The multiplication of '+f_Num+' and '+l_Num+' is: '+mul);
When the above code is executed, it produces the following result
The multiplication of 7 and 5 is: 35
Program 2
Here, We use the multiplication(-) operator to find the product of two numbers. The program calculates the product of two numbers 32 and 20 then the output is displayed here using HTML
<html> <head> <title>multiplication of two numbers</title> <script> var firstNum=32; var lastNum=20;//Decare and initiaize variabes var mul=firstNum*lastNum;//Calculate multiplication of given numbers document.write("Multiplication of "+firstNum+" and "+lastNum+" is: "+mul); //print result on the screen </script> </head> <body> </body> </html>
When the above code is executed, it produces the following result
Multiplication of 32 and 20 is: 640
Program 3
The program asks the user to enter two numbers using the form , then the result of the multiplication of two numbers is displayed when the user clicks the “multiply” button.
<html> <head> <title>Multiplication of two numbers</title> <script> function mul()//function to multiplication { var f_Num,l_Num,dif; f_Num=Number(document.getElementById("first").value); l_Num=Number(document.getElementById("second").value); multiply=f_Num*l_Num; document.getElementById("ans").innerHTML="Multiply:"+multiply; } </script> </head> <body> <p>Enter the first Number:<input type="text" id="first"></p> <p>Enter the second Number:<input type="text" id="second"></p> <button >When the above code is executed, it produces the following result
Similar post
Java program to multiply two numbers
C program to multiply two numbers
C++ program to multiply two numbers
Python program to multiply two numbers
Java program to multiply two floating-point numbers
C program to multiply two floating-point numbers
C++ program to multiply two floating-point numbers
Python program to multiply two floating-point numbers
Java program to multiply two numbers using methods
C program to multiply two numbers using function
C++ program to multiply two numbers using function
Python program to multiply two numbers function
PHP subtraction of two numbers
PHP addition of two numbers using function
PHP subtraction of two numbers using function
How to find reverse number using method In this article, we will discuss the concept…
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…