Home > Article > Backend Development > Program to calculate the area and perimeter of a rhombus, given what are the diagonals? In C++, what is a rhombus?
In geometry, a rhombus is a quadrilateral with four sides of the same length. A rhombus is similar in shape to a rhombus. If the diagonals of a rhombus are at right angles, then it becomes a square.
The properties of a rhombus are-
The picture below is a rhombus
Given the diagonal, assume that the task of d1 and d2 is to find the rhombus The area and perimeter of a cuboid, where area is the space occupied by the shape and perimeter is the space its boundaries will cover
To calculate the area and perimeter of a cuboid, there is a formula -
Input-: d1=6 and d2=12 Output-: The perimeter of rhombus with given diagonals are :26 The area of rhombus with given diagonals are :36
Start Step 1 -> declare function to calculate perimeter of rhombus int perimeter(int d1, int d2) Declare variable long long int perimeter Set perimeter = 2 * sqrt(pow(d1, 2) + pow(d2, 2)) Print perimeter Step 2 -> Declare function to calculate area of rhombus int area(int d1, int d2) Declare long long int area Set area = (d1 * d2) / 2 Print area Step 3 -> In main() Declare variable int d1 = 6, d2 = 12 Call perimeter(d1, d2) Call area(d1, d2) Stop
#include <iostream> #include <math.h> using namespace std; // program to calculate perimeter of rhombus int perimeter(int d1, int d2){ long long int perimeter; perimeter = 2 * sqrt(pow(d1, 2) + pow(d2, 2)); cout<< "The perimeter of rhombus with given diagonals are :"<<perimeter; } //program to calculate area of rhombus int area(int d1, int d2){ long long int area; area = (d1 * d2) / 2; cout<<"</p><p>The area of rhombus with given diagonals are :"<< area; } int main(){ int d1 = 6, d2 = 12; perimeter(d1, d2); area(d1, d2); return 0; }
The perimeter of rhombus with given diagonals are :26 The area of rhombus with given diagonals are :36
The above is the detailed content of Program to calculate the area and perimeter of a rhombus, given what are the diagonals? In C++, what is a rhombus?. For more information, please follow other related articles on the PHP Chinese website!