Showing posts with label Addition of Three Numbers Using Two Dimensional Array Using JavaScript. Show all posts
Showing posts with label Addition of Three Numbers Using Two Dimensional Array Using JavaScript. Show all posts

Thursday, October 29, 2015

Addition of Three Numbers Using Two Dimensional Array Using JavaScript

JavaScript is one of the hottest programming language now a days because of the intensive use of the Internet it is very seldom to see a website that does not use JavaScript in one way to another to make a website more interactive. In this article I would like to share with you another program that I wrote to understand the concept of two dimensional array in JavaScript.

Technically speaking JavaScript does not have a two or multidimensional array as data structure it only relies on one dimensional array but surprisingly creating two dimensional array in JavaScript is very easy. The sample program that I will share is an addition of three numbers using two dimensional array in JavaScript. I hope you will find my work useful and learn from it.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.


Program Listing

<html>
<body>
<style>
h3 {
   font-family:arial;
   };
 </style>
<script>
var arr  = [];

val1 = Number(prompt("Enter First Value :"));
val2 = Number(prompt("Enter Second Value : "));
val3 = Number(prompt("Enter Third Value : "));

var arr1 = [val1,val2,val3];

arr.push(arr1);

a = arr[0][0];
b = arr[0][1];
c = arr[0][2];

var solve_add = (a+b+c);

document.write("<h3> Addition of Three Numbers Using Two Dimensional Array </h3>");
document.write("<font face='arial' size=4>Value store ");
document.write("in variable A is " + a + ".</font><br>");
document.write("<font face='arial' size=4>Value store ");
document.write("in variable B is " + b + ".</font><br>");
document.write("<font face='arial' size=4>Value store ");
document.write("in variable C is " + c + ".</font><br>");
document.write("<br>");
document.write("<font face='arial' size=4>The sum of " + a );
document.write(" , " + b + " and " + c + " is " + solve_add + ".");
</script>
</body>
</html>