Explanation
A rectangle has four sides in which sides opposite to each other are equal. The perimeter of the rectangle is the area around its outside.
Suppose a, b, c, d are the four sides of rectangle.
a=c and b=d
Perimeter Of Rectangle= a+ b+ c+ d= a+ b+ a+ b= 2(a + b).
Algorithm
- Define Values for the side of the rectangle
- Apply values in the formula.
- Print the Perimeter.
Complexity
O(1)
Input:
a = c = 5
b = d = 4
Output:
Perimeter of Rectangle = 2 * ( a + b);
= 2 * (5 + 4)
= 18.00000
Python
Output:
C
Output:
JAVA
Output:
C#
Output:
PHP
Output: