multiply

JavaScript Program to multiply of Two Numbers

JavaScript Program to multiply of Two Numbers

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

Multiplication of two numbers

Multiply two numbers

JavaScript program for multiplying two numbers

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

 

JavaScript program for multiplying of two numbers using HTML

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

 

JavaScript program for multiplying of two numbers using function

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

Multiplication

 

 

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 addition of two numbers

PHP subtraction of two numbers

PHP addition of two numbers using function

PHP subtraction of two numbers using function

 

Function to multiply two numbers in PHP
C Program to multiplication table using Array
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

How to find reverse number using method in Java

How to find reverse number using method In this article, we will discuss the concept…

2 days ago

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago