C Program to Find Area and Circumference of a Circle वृत्त का क्षेत्रफल एवं परिधि ज्ञात करने का प्रोग्राम

In C language, the area and circumference of a circle can be calculated when its radius is given. The mathematical formulas are used to perform these calculations.

सी लैंग्वेज में वृत्त की त्रिज्या (Radius) दी गई होने पर उसका क्षेत्रफल (Area) तथा परिधि (Circumference) ज्ञात की जा सकती है। इनकी गणना के लिए गणितीय सूत्रों का प्रयोग किया जाता है।

Formulas सूत्र:

Area of Circle = π × r × r

Circumference of Circle = 2 × π × r

Where r represents the radius of the circle and π (pi) is approximately 3.14.

जहाँ r वृत्त की त्रिज्या है तथा π (पाई) का लगभग मान 3.14 लिया जा सकता है।

C Program

#include <stdio.h>

int main(void)
{
    const float pi = 3.14f;
    float r, area, cir;

    printf("Enter the radius of a circle: ");
    scanf("%f", &r);

    if (r <= 0)
    {
        printf("Radius must be a positive value.\n");
    }
    else
    {
        area = pi * r * r;
        cir = 2 * pi * r;

        printf("Area of circle = %.2f\n", area);
        printf("Circumference of circle = %.2f\n", cir);
    }

    return 0;
}

Output

Enter the radius of a circle: 5
Area of circle = 78.50
Circumference of circle = 31.40

Explanation व्याख्या

In this program, the user enters the radius of the circle, which is stored in variable r.

इस प्रोग्राम में यूजर वृत्त की त्रिज्या इनपुट करता है, जिसे r वेरिएबल में स्टोर किया जाता है।

The statement const float pi = 3.14f; declares a constant variable pi whose value cannot be changed during normal program execution.

स्टेटमेंट const float pi = 3.14f; एक कॉन्स्टेंट वेरिएबल pi घोषित करता है, जिसकी वैल्यू प्रोग्राम में सामान्य रूप से बदली नहीं जा सकती।

The area is calculated by multiplying pi by the square of the radius.

त्रिज्या के वर्ग को पाई से गुणा करके वृत्त का क्षेत्रफल ज्ञात किया जाता है।

The circumference is calculated by multiplying twice the value of pi by the radius.

पाई के मान को त्रिज्या से दो गुना गुणा करके वृत्त की परिधि ज्ञात की जाती है।

The if condition checks that the radius is positive before performing the calculations.

गणना करने से पहले if कंडीशन यह जाँचती है कि त्रिज्या धनात्मक है।

Comments

Popular posts from this blog

C Language Topics in Hindi and English

Top High-Paying Tech Skills to Learn in 2025

Complete C Programming Syllabus | Advanced C Roadmap for Students