Perimeter and Area of Varignon’s Parallelogram
Last Updated :
07 Jul, 2022
Given a and b are the lengths of the diagonals AC and BD of a quadrilateral ABCD with the area of quadrilateral as s. The task is to find the perimeter and area of the Varignon’s parallelogram PQRS.
Note: When we join the mid-points of the sides of any quadrilateral, the new quadrilateral formed inside will always be a parallelogram and this parallelogram is known as the Varignon’s parallelogram named upon the French Mathematician Pierre Varignon. Thus, PQRS will be a parallelogram since it is formed by joining the mid-points of quadrilateral ABCD as shown below:
Example:
Input: a = 7, b = 8, s = 10
Output: Perimeter = 15, Area = 5
Approach: The perimeter of Varignon’s parallelogram PQRS is equal to the sum of the length of the diagonals of quadrilateral ABCD.
Hence, Perimeter = a + b, where a and b are lengths of diagonals AC and BD.
Also, the area of the Varignon’s parallelogram is always half the area of quadrilateral ABCD.
Hence, Area = s / 2, where s is the area of quadrilateral ABCD.
Below is the implementation of the above approach:
C++
#include <bits/stdc++.h>
using namespace std;
float per( float a, float b) { return (a + b); }
float area( float s) { return (s / 2); }
int main()
{
float a = 7, b = 8, s = 10;
cout << per(a, b) << endl;
cout << area(s) << endl;
return 0;
}
|
C
#include <stdio.h>
float per( float a, float b) { return (a + b); }
float area( float s) { return (s / 2); }
int main()
{
float a = 7, b = 8, s = 10;
printf ( "%f\n" , per(a, b));
printf ( "%f" , area(s));
return 0;
}
|
Java
import java.lang.*;
class GFG {
public static double per( double a, double b)
{
return (a + b);
}
public static double area( double s) { return (s / 2 ); }
public static void main(String[] args)
{
double a = 7 , b = 8 , s = 10 ;
System.out.println(per(a, b));
System.out.println(area(s));
}
}
|
Python3
def per(a, b):
return (a + b)
def area(s):
return (s / 2 )
a = 7
b = 8
s = 10
print (per(a, b))
print (area(s))
|
C#
using System;
class GFG {
public static double per( double a, double b)
{
return (a + b);
}
public static double area( double s) { return (s / 2); }
public static void Main()
{
double a = 7.0, b = 8.0, s = 10.0;
Console.WriteLine(per(a, b));
Console.Write(area(s));
}
}
|
PHP
<?php
function per( $a , $b )
{
return ( $a + $b );
}
function area( $s )
{
return ( $s / 2 );
}
$a =7;
$b =8;
$s =10;
echo (per( $a , $b ) "" );
echo "\n" ;
echo (area( $s ));
?>
|
Javascript
<script>
function per(a , b)
{
return (a + b);
}
function area(s)
{
return (s / 2);
}
var a = 7, b = 8, s = 10;
document.write(per(a, b));
document.write(area(s));
</script>
|
Time complexity: O(1)
Auxiliary Space: O(1)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...