VOOZH about

URL: https://www.geeksforgeeks.org/computer-science-fundamentals/program-to-find-diameter-with-the-given-radius-of-a-circle/

⇱ Program to find diameter with the given radius of a circle. - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Program to find diameter with the given radius of a circle.

Last Updated : 29 Jan, 2024

Given the radius of a circle, write a program to find the diameter of a circle.

Examples:

Input: r=4
Output: 8

Input: r=5
Output:10

Approach:

The diameter of a circle is simply twice the radius.

Here's how you could express this formula in a mathematical sense:

D= 2* r
r is radius and D is diameter of a circle

Below is the implementation of the code:


Output
The Given radius of the circle is: 4
The diameter of the circle is : 8

Time Complexity: O(1), since there is one multiplication operation which takes constant time.
Auxiliary Space: O(1), since no extra space has been taken.

Comment
Article Tags: