![]() |
VOOZH | about |
Given the radius of a circle, write a program to find the diameter of a circle.
Examples:
Input: r=4
Output: 8Input: 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:
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.