C program, algorithm, flowchart & explanation to calculate the area and circumference of a circle.

C program to calculate the area and circumference of a circle

Write a C program to calculate the area and circumference of a circle:-

Here, we have to write a simple C program that takes a radius value by the user and gives circumference and area values as output.

Formulae used:-

Area= Pi*radius*radius

Circumference= 2*Pi*radius

Explanation & Program code:-

We will ask the user to enter the value of the radius, then we will store the entered value in a variable. Based on the entered radius value, we will calculate the area and circumference of the circle. To make the program code easier we have taken the standard Pi value as 3.14, you can also take the Pi value as 22/7 for a more accurate result. Further details are mentioned as comments in the program code.

C
#include <stdio.h>
#include <math.h>
int main()                                                    /*Start*/
{
    float r,cir,area;                                         /* Decleration of variable*/
    printf("Enter the radius of circle:-");                   /*Read radius of circle*/
    scanf("%f",&r);
    cir=2*3.14*r;                                             /*circumferance=2*𝝅*r*/
    printf("Circumferance of the circle:-%.2f\n",cir);        /*print circumferance*/
    area=3.14*r*r;                                            /*area=3.14*r*r*/
    printf("Area of the circle:-%.2f\n",area);                /*print area*/
    return 0;                                                 /*Stop*/
}

Output:-

C
Enter the radius of circle:-5
Circumferance of the circle:-31.40
Area of the circle:-78.50

Algorithm of program to calculate the area and circumference of a circle:-

Step 1:- Start.
Step 2:- Declaration of variables.
Step 3:- Read the radius of the circle.
Step 4:- Circumferance=2*𝝅*r.
Step 5:- Print circumference.
Step 6:- Area=3.14*r*r.
Step 7:- Print area.
Step 8:- Stop.

Flowchart of the program to calculate the area and circumference of a circle:-

Flowchart to calculate the area and circumference of a circle.

As you have reached the end of the article, so I hope as of now you have a clear understanding of the program, algorithm, and flowchart to calculate the area and circumference of a circle. Please let me know your queries, suggestion, and feedback in the comment section.

Leave a Comment

Your email address will not be published.