- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find the Diameter or Longest chord of a Circle in C++
Suppose we have radius r is given. We have to find the diameter or longest chord of the circle. If the radius is 9, and diameter will be 18. This task is extremely simple, we have to find the 2*r, that is the diameter of the circle.
Example
#include<iostream> using namespace std; int getDiameter(int r) { return 2*r; } int main() { int r = 9; cout << "The longest chord or diameter is : " << getDiameter(r); }
Output
The longest chord or diameter is : 18
Advertisements