C++ program to calculate the area of kite

Hey, guys today we are going to learn how to write a program to calculate the area of a kite. Before starting with the program, let us study the shape of the kite. Kite is a two-dimensional (2D) quadrilateral having perpendicular diagonals and it’s one diagonal is the line of symmetry. A kite is a quadrilateral with two pair of equal-length sides that are adjacent to each other. Also, the angles where the two pairs meet are equal.

Kite geometry

There are 2 ways to find the area of a kite:

  1. Multiplying the lengths of diagonals of kite and dividing it by 2
  2. Multiplying the lengths of 2 unequal sides by the sine of the angle between them.

1. Program to find Area of a kite by method 1(Multiplying the lengths of the diagonals of the kite and dividing it by two)

We would ask the user to enter the lengths of the diagonals of kite ‘d1’ and ‘d2’. Then we will calculate the area of the kite by using the formula Area=(d1×d2)/2.

#include <iostream>

using namespace std;
int main()
{
    float d1,d2,area;
    //Inputing the lengths of the diagonals of the kite 
    cout<<"Enter the length of diagonal 1 of the kite";
    cin>>d1;
    cout<<"\n Enter the length of diagonal 2 of the kite";
    cin>>d2;
    //Calculating the area 
    area=(d1*d2)/2;
    cout<<"\n Area of the given kite = \t"<<area;
    return 0;
}

Output:

 Enter the length of diagonal 1 of the kite 15.6                                                                                                      
                                                                                                                                                   

 Enter the length of diagonal 2 of the kite 13.5                                                                                                     
                                                                                                                                                     

 Area of the given kite =       105.3

2. Program to find Area of a kite by method 2(Multiplying lengths of 2 unequal sides by the sine of the angle between them)

We would ask the user to enter the lengths of the 2 unequal sides ‘a’ and  ‘b’ and the angle ‘c’ between them. Then we will calculate area by using the formula Area = a×b×sin(c)

Area

For calculating the sine of the angle between the sides we will use sin() function of <math.h> or <cmath> header file.
Note: sin() takes an angle in radians as input and returns sin of it.

#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    float a,b,c,area;
    //Inputing the lengths of the diagonals of the kite 
    cout<<"Enter the length of side 1 of the kite";
    cin>>a;
    cout<<"\n Enter the length of side 2 of the kite";
    cin>>b;
    cout<<"\n Enter the angle between two sides(In Radians)";
    cin>>c;
    //Calculating the Area
    area=a*b*sin(c);
    cout<<"\n Area of the given kite = \t"<<area;
    return 0;
}

Output:

 Enter the length of side 1 of the kite 5                                                                                                             
                                                                                                                                                

 Enter the length of side 2 of the kite 4                                                                                                            
                                                                                                                                                  

 Enter the angle between two sides(In Radians) 1.345                                                                                                 
                                                                                                                                                   

 Area of the given kite =       19.4923

Also, refer :

Leave a Reply

Your email address will not be published. Required fields are marked *