
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Diagonal of a Regular Pentagon in C++ Program
In this tutorial, we are going to learn how to find the diagonal of a regular pentagon.
We have to find the length of the diagonal of the regular pentagon using the given side. The length of the diagonal of a regular pentagon is 1.22 * s where s is the side of the pentagon.
Example
Let's see the code.
#include <bits/stdc++.h> using namespace std; float pentagonDiagonal(float s) { if (s < 0) { return -1; } return 1.22 * s; } int main() { float s = 7; cout << pentagonDiagonal(s) << endl; return 0; }
Output
8.54
Conclusion
If you have any queries in the tutorial, mention them in the comment section.
- Related Articles
- Diagonal of a Regular Pentagon in C++?
- Diagonal of a Regular Heptagon in C++ Program
- Diagonal of a Regular Heptagon in C++?
- Diagonal of a Regular Hexagon in C++?\n
- Program to find the Area of a Pentagon in C++
- The perimeter of a regular pentagon is 65 cm. Find the length of each side.
- Swift Program to Calculate Area of Pentagon
- The perimeter of a regular pentagon is \( 100 \mathrm{~cm} \). How long is its each side?
- A regular pentagon $ABCDE$ and a square $ABFG$ are formed on opposite sides of $AB$. Find $\angle BCF$.
- Area of hexagon with given diagonal length in C Program?
- Program to sort each diagonal elements in ascending order of a matrix in C++
- Program to convert given Matrix to a Diagonal Matrix in C++
- A piece of a string is 60 cm long what will be the length of each side if the given string is used to form:A) A square B) An equilateral triangle C) A regular pentagon D) A regular hexagon E) A regular decagon
- Print numbers in matrix diagonal pattern in C Program.
- Diagonal Sum of a Binary Tree in C++?

Advertisements