division

JavaScript: Calculate division of Two Numbers

JavaScript: Calculate the division of Two Numbers

In this tutorial, we will discuss the title of the JavaScript: Calculate division of Two Numbers

In this topic, we are going to learn how to write a program to divide two numbers in the JavaScript programming language.

Division of two numbers

Division of two num

JavaScript program for dividing two numbers

Program 1

Here, We use the division(/) operator to find the division of the given two numbers.

The program calculates the division of the two numbers 70 and 5; the output is displayed here.

// JavaScript program to division of two number
const f_Num=70;
//declare and initaiize variable f_Num
const l_Num=5;
//declare and initaiize variable l_Num

//calculate division of given two numbers
const div=f_Num/l_Num;

//display the division of two numbers
console.log('The division of '+f_Num+' and '+l_Num+' is: '+div);

When the above code is executed, it produces the following result

The division of 70 and 5 is: 14

 

JavaScript program for dividing two numbers using HTML

Program 2

Here, We use the division(/) operator to find the division of two numbers. The program calculates the division of two numbers 30 and 5 then the output is displayed here using HTML

<html>
<head>
<title>Division of two numbers</title>
<script>
var fNumber=30;
var lNumber=5;
//Decare and initiaize variabes
var div=fNumber/lNumber;
//Calculate division of the given numbers 
//and assign the value to div variable
document.write("Division of "+fNumber+" and "+lNumber+" is: "+div);
//print result on the screen using div variable
</script>
</head>
<body>

</body>
</html>

When the above code is executed, it produces the following result

Division of 30 and 5 is: 6

 

 

JavaScript program for dividing two numbers using the function

Program 3

The program asks the user to enter two numbers using the form, then the result of the division of two numbers is displayed when the user clicks the “division” button.

<html>
<head>
<title>Division of two numbers</title>
<script>
function div()//function to find division of given numbers
{
var fNum,lNum,division;
fNum=Number(document.getElementById("first").value);
sNum=Number(document.getElementById("second").value);
division=fNum/sNum;
document.getElementById("ans").innerHTML="Division:"+division;
}

</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

Outpt

 

 

Similar post

Java program to divide two numbers

C program to divide two numbers

C++ program to divide two numbers

Python program to divide two numbers

 

Java program to divide two floating-point  numbers

C program to divide two floating-point numbers

C++ program to divide two floating-point numbers

Python program to divide two floating-point numbers

 

 

 

 

JavaScript Program to substract Two Numbers
Program to convert Celsius into Fahrenheit in Java
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