Javascript program to enter length and breadth of a rectangle and find its perimeter
ADVERTISEMENTS
Javascript program to enter the length and breadth of a rectangle and find its perimeter. There are you will learn how to find the perimeter of a rectangle in javascript language.
Formula:
P = 2(l + w)
where:
P
= perimeter
l
= length of the rectangle
w
= width of the rectangle
Let us understand this through Javascript program:
<script type="text/javascript">
/*
Javascript program to find the perimeter of a rectangle
*/
var l, w, p;
l = 5;
w = 9;
/* Calculate perimeter of rectangle */
p = 2 * (l + w);
document.write("The Perimeter of rectangle = " + p + " units");
</script>
Output Screen:
The Perimeter of rectangle = 28 units