Home > Backend Development > C++ > Program to find the perimeter of a rhombus using diagonals

Program to find the perimeter of a rhombus using diagonals

WBOY
Release: 2023-08-27 15:05:09
forward
972 people have browsed it

A rhombus is a simple quadrilateral with all four sides having the same length. The perimeter of a rhombus can be found in two ways.

  1. Add all edges.
  2. Using diagonals

A quadrilateral has two diagonals. The area and perimeter of the quadrilateral can be found based on the length of the diagonals.

Using the diagonal of the rhombus to find the perimeter of the rhombus is 2{√(d1)2 (d2)2 }

Program to find the perimeter of a rhombus using diagonals

Logic - Use the diagonals of a rhombus to find its perimeter. You need the formula 2{√(d1)2 (d2)2 } In your code you need to use a math class that supports squareRoot and the squaring of numbers.

The following code shows a program to find the perimeter of a rhombus using its diagonals.

Example

#include <stdio.h>
#include <math.h>
int main(){
   int d1 = 3, d2= 4, perimeter;
   perimeter = (2 * sqrt(pow(d1,2)+pow(d2,2)));
   printf("perimeter is %d", perimeter);
   return 0;
}
Copy after login

Output

perimeter is 10
Copy after login

The above is the detailed content of Program to find the perimeter of a rhombus using diagonals. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template