Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Diagonal of a Regular Pentagon in C++?
To find the length for the diagonal of a regular pentagon we put the value of side in (1+√5)side/2 = (1+2.24)side/2.
Example
Let us see the following implementation to get the regular Heptagon diagonal from its side −
#include <iostream>
using namespace std;
int main(){
float side = 5;
if (side < 0)
return -1;
float diagonal = (1+2.24) *(side/2);
cout << "The diagonal of the regular pentagon = "<<diagonal<< endl;
return 0;
}
Output
The above code will produce the following output −
The diagonal of the regular pentagon = 8.1
Advertisements