
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 Area of a parallelogram
In this article, we will understand how to find the area of a parallelogram. The area of a parallelogram is calculated using the formula by ?
base * height
Below is a demonstration of the same ?
Suppose our input is ?
Base: 6 Height: 8
The desired output would be ?
Area of parallelogram is: 48
Algorithm
Step 1 ? START.
Step 2 ? Declare three values namely base, height and myResult.
Step 3 ? Define the values.
Step 4 ? Calculate the area using the formula by base * height and store the result.
Step 5 ? Display the result.
Step 6 ? Stop.
Example 1
In this example, we will find the area of a Parallelogram with the base and height. First, we will declare and initialize the variables for base height.
val base = 5 val height = 8
Then, we will find the area using the formulae given above. The area of parallelogram will get saved in the variable myResult.
val myResult = base * height
Let us see the final example to find the area of a Parallelogram with the base and height.
fun main() { val base = 5 val height = 8 println("The sides of the parallelogram are defined as $base, $height, $base, $height") val myResult = base * height println("The area of parallelogram is: $myResult") }
Output
The sides of the parallelogram are defined as 5, 8, 5, 8 The area of parallelogram is: 40
Example 2
In this example, we will find the Area of a parallelogram ?
fun main() { val base = 5 val height = 8 println("The sides of the parallelogram are defined as $base, $height, $base, $height") areaParallelogram(base, height) } fun areaParallelogram(base: Int, height: Int) { val myResult = base * height println("The area of parallelogram is: $myResult") }
Output
The sides of the parallelogram are defined as 5, 8, 5, 8 The area of parallelogram is: 40