- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Kotlin Program to Find the Perimeter of a Rectangle

In this article, we will understand how to find the perimeter of a rectangle. The Perimeter of a rectangle is calculated using the following formulae

2*(length + width)

Below is a demonstration of the same −

Suppose our input is

The length of the sides of a rectangle are: 5, 8, 5, 8

The desired output would be

Perimeter : 26

## Algorithm

**Step 1**− START**Step 2**− Declare three integer variables length, width and myResult.**Step 3**− Define the values.**Step 4**− Calculate the perimeter using the formula 2 * (length + width), store the output in myResult**Step 5**− Display the Perimeter value**Step 6**− STOP

## Example 1

In this example, we will find the Perimeter of a Rectangle using the above given formulae. First, declare and set the variables length and width −

val length = 5 val width = 8

Then, find the Perimeter of Rectangle using the length and width

val myResult = 2 * (length + width)

Let us see the example to calculate the Perimeter of Rectangle −

fun main() { val length = 5 val width = 8 println("The sides of the rectangle are defined as $length, $width, $length, $width") val myResult = 2 * (length + width) println("Perimeter of rectangle is: $myResult") }

## Output

The sides of the rectangle are defined as 5, 8, 5, 8 Perimeter of rectangle is: 26

## Example 2

In this example, we will find the perimeter of a Rectangle

fun main() { val length = 5 val width = 8 println("The sides of the rectangle are defined as $length, $width, $length, $width") getPerimeter(length, width) } fun getPerimeter(length: Int, width: Int) { val myResult = 2 * (length + width) println("Perimeter of rectangle is: $myResult") }

## Output

The sides of the rectangle are defined as 5, 8, 5, 8 Perimeter of rectangle is: 26

- Related Questions & Answers
- Java Program to Find the Perimeter of a Rectangle
- Program to find Perimeter / Circumference of Square and Rectangle in C++
- C Program for Area And Perimeter Of Rectangle
- Java Program to find the perimeter of a cylinder
- Java Program to Find the Perimeter of a Circle
- Program to find the perimeter of a rhombus using diagonals
- Java program to find the area of a rectangle
- Python Program for Find the perimeter of a cylinder
- Find the perimeter of a cylinder in Python Program
- Sum of perimeter of all the squares in a rectangle using JavaScript
- C++ Program to get minimum perimeter of rectangle whose area is n
- Program to find perimeter of a polygon in Python
- Program to find the Area and Perimeter of a Semicircle in C++
- Python Program to Find the Area of a Rectangle Using Classes
- Golang Program to Find the Area of a Rectangle Using Classes
- Program to find the perimeter of an island shape in Python