Given the sides of Parallelogram then calculate the circumference.
Examples :
Input: a = 10, b = 8
Output: 36.00
Input: a = 25.12, b = 20.4
Output: 91.04
The opposite sides of a parallelogram are of equal length and parallel. The angles are pairwise equal but not necessarily 90 degree. The circumference of a Parallelogram can be computed as sum of two adjacent sides each multiplied by 2.

Formula used to calculate circumference of a Parallelogram:
(2*a)+(2*b)
C++
#include <stdio.h>
float circumferenceparallelogram(float a, float b)
{
return ((2 * a) + (2 * b));
}
int main()
{
float a = 10, b = 8;
printf("Circumference of a given Parallelogram is : %.2f",
circumferenceparallelogram(a, b));
return 0;
}
|
Java
import java.io.*;
class GFG
{
static float circumferenceparallelogram(float a, float b)
{
return ((2 * a) + (2 * b));
}
public static void main(String arg[])
{
float a = 10, b = 8;
System.out.print("Circumference of a given Parallelogram is :");
System.out.println(circumferenceparallelogram(a, b));
}
}
|
Python3
def circumferenceparallelogram(a,b):
return ((2 * a) + (2 * b))
a = 10
b = 8
print("Circumference of a given Parallelogram is :",
round(circumferenceparallelogram(a, b),4))
|
C#
using System;
class GFG
{
static float circumferenceparallelogram(float a,
float b)
{
return ((2 * a) + (2 * b));
}
public static void Main()
{
float a = 10, b = 8;
Console.Write("Circumference of a" +
"given Parallelogram is :");
Console.Write(circumferenceparallelogram(a, b));
}
}
|
PHP
<?php
function circumferenceparallelogram( $a, $b)
{
return ((2 * $a) + (2 * $b));
}
$a = 10; $b = 8;
echo "Circumference of a ".
"given Parallelogram is : ",
circumferenceparallelogram($a, $b);
?>
|
Javascript
<script>
function circumferenceparallelogram(a, b)
{
return ((2 * a) + (2 * b));
}
let a = 10, b = 8;
document.write("Circumference of a given Parallelogram is : ",
circumferenceparallelogram(a, b));
</script>
|
Output :
Circumference of a given parallelogram is : 36.0
Time Complexity: O(1)
Auxiliary Space: O(1)
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!
Last Updated :
20 Feb, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...