TeachingBee

Area of Circle Program in C

Area of circle program in c-teachingbee

In this blog post, we will checkout the area of circle program in C programming. The area of a circle is given by the formula ( πr^2 ), where ( r ) is the radius of the circle and (π) (Pi) is a constant approximately equal to 3.14159. This formula is a cornerstone in geometry and is pivotal in various applications across science and engineering fields. Our focus will be on implementing this formula in a C program to efficiently compute the area, providing a practical approach to understanding mathematical concepts through programming.

area of circle

Area of Circle Formula

Area =  π * Radius * Radius

Where value of pie = 3.14159 and radius will be given by the user.

How to Write Area of Circle Program in C?

To create a C program for finding the area of a circle, you can follow this algorithm and corresponding pseudo code.

Algorithm:

  1. Start: Begin the process.
  2. Input Radius: Prompt the user to input the radius of the circle.
  3. Calculate Area: Use the formula Area = π * Radius * Radius to calculate the area of the circle.
  4. Display Area: Show the calculated area to the user.
  5. End: Conclude the process.

Pseudo Code:

BEGIN
    DECLARE radius, area AS FLOAT
    PRINT "Enter the radius of the circle: "
    READ radius
    area = π * radius * radius
    PRINT "The area of the circle with radius ", radius, " is: ", area
END

C Program to Find Area of Circle

#include <stdio.h>

int main() {
    double radius, area;
    // initializing the value of pi
    double pi = 22.0 / 7.0;

    // Prompt user and get radius
    printf("Enter the radius of the circle: ");
    scanf("%lf", &radius);  // %lf for reading double

    // Calculate area
    area = pi * radius * radius;  // M_PI is from math.h

    // Display the area
    printf("The area of the circle with radius %.2lf is: %.2lf\n", radius, area);

    return 0;  // End of program
}

Output

C Program to Find Area of Circle

In the above program, first, we initialise the variable pi with the value of π and take input for radius then using the area of circle formula calculated the area of the circle.

Time Complexity: The time complexity of this program is O(1). This is because the calculation of the area of a circle is achieved through a straightforward arithmetic expression that does not depend on iterative or recursive processes.

Space Complexity: The space complexity is also O(1). This is because program uses few variables which doesn’t not grow with the input size.

Conclusion

  • On a plane, a shape’s area is the amount of space it covers.
  • When the radius is given, the area of a circle is Area=π∗(radius)2Area=π∗(radius)2
  • Using the above we have discussed area of circle program in C.

If you liked this post you can checkout other C Programs.

FAQ

What is the formula of area of C?

Can the same program be used to find the area of a circle with a different programming language?

Are there any libraries or functions available in C for calculating the area of a circle?

90% of Tech Recruiters Judge This In Seconds! 👩‍💻🔍

Don’t let your resume be the weak link. Discover how to make a strong first impression with our free technical resume review!

Related Articles

Subtraction of Two Numbers Program in C

In this blog post, we will checkout the Subtraction of Two Numbers Program in C. How to Write Subtraction Program in C? To create a C program to subtract two

Add Two Numbers In C

In this blog post, we will checkout the how to add two numbers in C. Algorithm to Add Two Numbers in C To create a C program to add two

Why Aren’t You Getting Interview Calls? 📞❌

It might just be your resume. Let us pinpoint the problem for free and supercharge your job search. 

Newsletter

Don’t miss out! Subscribe now

Log In