Find the Diameter or Longest chord of a Circle in C++

C++Server Side ProgrammingProgramming

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.


 Live Demo

using namespace std;
int getDiameter(int r) {
   return 2*r;
int main() {
   int r = 9;
   cout << "The longest chord or diameter is : " << getDiameter(r);


The longest chord or diameter is : 18
Updated on 19-Dec-2019 11:25:00