- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- 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 Articles
- Java Program to Find the Perimeter of a Rectangle
- Swift Program to Find the Perimeter of a Rectangle
- Kotlin Program to Find the Perimeter of a Circle
- JavaScript program to find Area and Perimeter of Rectangle
- How to find the Perimeter of a Rectangle in Golang?
- Program to find Perimeter / Circumference of Square and Rectangle in C++
- Java Program to Find out the Area and Perimeter of Rectangle using Class Concept
- C Program for Area And Perimeter Of Rectangle
- The length of a rectangle is 50 cm if the perimeter of the rectangle is 150 cm. Find the area of the rectangle.
- The length of rectangle is $25\ m$ and width of rectangle is $56\ cm$ find the perimeter of rectangle.
- Find the Perimeter of Triangle ABC.Find the Perimeter of Rectangle BCDE. from the following figure."\n
- A rectangle has a length 15 cm and the perimeter is 50 cm. Find the breadth of the rectangle.
- The length of a rectangle is 16 cm. If the perimeter of the rectangle is 60 cm then find the breadth of the rectangle.
- The perimeter of a rectangle is $130\ cm$. If the breadth of the rectangle is $30\ cm$, find its length. Also find the area of the rectangle.
- Java program to find the area of a rectangle