From 47713533e751bab8e900314539192a93299e6489 Mon Sep 17 00:00:00 2001 From: rahuldevpresient Date: Tue, 15 Sep 2026 11:58:46 +0530 Subject: [PATCH] Used optimal approach Earlier PI value was hardcoded, but now it is defined in the header for optimal programming practice --- Lab_01/07_circle.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lab_01/07_circle.cpp b/Lab_01/07_circle.cpp index 5d68352..1515f75 100644 --- a/Lab_01/07_circle.cpp +++ b/Lab_01/07_circle.cpp @@ -1,6 +1,7 @@ // C++ program to Calculate Area and Circumference of Circle. #include +#define PI 3.14 using namespace std; @@ -12,8 +13,8 @@ int main() cin >> R; if (R > 0) { - Area = 3.14 * R * R; - Circumference = 2 * 3.14 * R; + Area = PI * R * R; + Circumference = 2 * PI * R; cout << "Area of Circle is " << Area << ";" << endl; cout << "Circumference of Circle is " << Circumference << ";" << endl; } @@ -23,4 +24,4 @@ int main() system("pause"); return 0; -} \ No newline at end of file +}