Program to find area of a circle Last Updated : 27 Dec, 2024 Comments Improve Suggest changes 9 Likes Like Report Try it on GfG Practice Given the radius r. Find the area of a circle. The area of the circle should be correct up to 5 decimal places. Examples:Input: r = 5Output: 78.53982Explanation: As area = PI * r * r = 3.14159265358979323846 * 5 * 5 = 78.53982, as we only keep 5 digits after decimal.Input: r = 2Output: 12.56637Explanation: As area = PI * r * r = 3.14159265358979323846 * 2 * 2 = 12.56637, as we only keep 5 digits after decimal.The area of a circle can be calculated using the formula: area = PI * r * r C++ #include <iostream> #include <cmath> #include <iomanip> using namespace std; float findArea(float r) { return (M_PI * r * r); } int main() { float r = 5, area; area = findArea(r); cout << fixed << setprecision(5) << area; return 0; } C #include <stdio.h> #include <math.h> #define PI 3.14159265358979323846 float findArea(float r) { return (PI * r * r); } int main() { float r = 5, area; area = findArea(r); printf("%.5f\n", area); return 0; } Java import java.lang.Math; class GfG { static float findArea(float r) { return (float)(Math.PI * r * r); } public static void main(String[] args) { float r = 5; float area = findArea(r); System.out.printf("%.5f%n",area); } } Python import math def findArea(r): return math.pi * r * r if __name__ == "__main__": r = 5 area = findArea(r) print(f"{area:.5f}") C# using System; class GfG { static float FindArea(float r) { return (float)(Math.PI * r * r); } static void Main() { float r = 5; float area = FindArea(r); Console.WriteLine("{0:F5}",area); } } JavaScript function findArea(r) { return Math.PI * r * r; } //Driver Code let r = 5; let area = findArea(r); console.log(area.toFixed(5)); Output78.53982Time Complexity: O(1)Auxiliary Space: O(1), since no extra space has been taken. Create Quiz Comment K kartik Follow 9 Improve K kartik Follow 9 Improve Article Tags : Mathematical Geometric DSA Basic Coding Problems area-volume-programs +1 More Explore DSA FundamentalsLogic Building Problems 2 min read Analysis of Algorithms 1 min read Data StructuresArray Data Structure 3 min read String in Data Structure 2 min read Hashing in Data Structure 2 min read Linked List Data Structure 2 min read Stack Data Structure 2 min read Queue Data Structure 2 min read Tree Data Structure 2 min read Graph Data Structure 3 min read Trie Data Structure 15+ min read AlgorithmsSearching Algorithms 2 min read Sorting Algorithms 3 min read Introduction to Recursion 15 min read Greedy Algorithms 3 min read Graph Algorithms 3 min read Dynamic Programming or DP 3 min read Bitwise Algorithms 4 min read AdvancedSegment Tree 2 min read Binary Indexed Tree or Fenwick Tree 15 min read Square Root (Sqrt) Decomposition Algorithm 15+ min read Binary Lifting 15+ min read Geometry 2 min read Interview PreparationInterview Corner 3 min read GfG160 3 min read Practice ProblemGeeksforGeeks Practice - Leading Online Coding Platform 1 min read Problem of The Day - Develop the Habit of Coding 5 min read Like