C Program to calculate Area and Circumference of Circle sirfpadhai

C Program to calculate Area and Circumference of Circle

C Program to calculate Area and Circumference of Circle sirfpadhai

यहां हम एक साधारण सी प्रोग्राम लिख रहे हैं जो उपयोगकर्ता द्वारा प्रदान किए गए त्रिज्या मान के आधार पर सर्कल के क्षेत्र और परिधि की गणना करता है।

Formula:

C = π * d = 2π * r
Area = 3.14 * radius * radius
Circumference = 2 * 3.14 * radius

Program to calculate Area and Circumference based on user input

क्षेत्रफल और परिधि की गणना करने के लिए हमें वृत्त की त्रिज्या ज्ञात करनी चाहिए। कार्यक्रम उपयोगकर्ता को त्रिज्या में प्रवेश करने के लिए प्रेरित करेगा और इनपुट के आधार पर यह मूल्यों की गणना करेगा। इसे आसान बनाने के लिए हमने प्रोग्राम में मानक PI मान 3.14 (स्थिर) के रूप में लिया है। अन्य विवरण नीचे दिए गए उदाहरण कार्यक्रम में टिप्पणियों के रूप में उल्लिखित हैं।

#include <stdio.h>
int main()
{
   int circle_radius;
   float PI_VALUE=3.14, circle_area, circle_circumf;

   //Ask user to enter the radius of circle
   printf("\nEnter radius of circle: ");
   //Storing the user input into variable circle_radius
   scanf("%d",&circle_radius);

   //Calculate and display Area
   circle_area = PI_VALUE * circle_radius * circle_radius;
   printf("\nArea of circle is: %f",circle_area);

   //Caluclate and display Circumference
   circle_circumf = 2 * PI_VALUE * circle_radius;
   printf("\nCircumference of circle is: %f",circle_circumf);

   return(0);
}

Output:-

Enter radius of circle: 2
Area of circle is: 12.560000
Circumference of circle is: 12.560000

यदि आप अधिक सटीक परिणाम चाहते हैं तो 3.14 के बजाय PI मान 22/7 लें, यह आपको क्षेत्रफल और परिधि के सटीक मान देगा।

Example 2:-

/*##Circumference Of Circle*/
/*##Calculation Programs, Datatype Programs, Basic Programs*/

#include<stdio.h>

float PI = 3.14;

int main(){
   float radius, ci;

   printf("\nEnter the radius of Circle : ");
   scanf("%f", &radius);

   ci = 2 * PI * radius;
   
   printf("\nCircumference of Circle : %f", ci);

   return (0);
}

Output:-

Enter the radius of Circle : 2

Circumference of Circle : 12.560000

Example 3:-

#include<stdio.h>
#include<conio.h>

void main()
{
  int r;
  float a, c;
  float pi=3.14;

  printf("ntenter value of radius=");
  scanf("%d",&r);

  a= pi*r*r;
  c=2*pi*r;

  printf("tArea = %.2fn",a);
  printf("tCircumference = %.2fn",c);

  getch();

}

Output:-

enter value of radius=5
Area  = 78.50
circumference = 31.40
Previous articleoperator overloading in c++ example in hindi | operator overloading in c++ full details.
Next articleAdvantages and Disadvantages of Recursion in c in Hindi

LEAVE A REPLY

Please enter your comment!
Please enter your name here