C program to calculate Area and Circumference of circle




Here, we will learn c program to find area and circumference of a circle. To find the area we have the formula area  area PI radius radius where PI is equal to 3.14 and to find the circumference of a circle we have  circumference = PI * radius again PI is equal to 3.14. It is a simple c program where we input the values of radius and take the PI value and substitute in the respective formula to find the area of the circle and the circumference of the circle.

ALGORITHM

1 Step: BEGIN.

2 Step: ENTER THE RADIUS OF THE CIRCLE.

3 Step: DECLARE THE VALUE OF PI=3.1415965 .

4 Step: PERFORM THE OPERATION                                                                                    area PI radius radius, circumf = PI * radius;

5 Step: PRINT THE RADIUS AND CIRCUMFERENCE OF THE GIVEN CIRCLE.

6 Step: EXIT.


 PROGRAM:- 

C program to find the area and circumference of a circle without user input.

Here in this program to find the area of the circle by taking the value of the radius as 4. And then substituting the value into the respective formula. Refer the program given below. In this program we are storing radius in a integer variable naming radius and storing 3.14 value in the PI variable and declaring area and circumf variables as float to store the area and circumference of a circle. After computing the values of area and circumference of a circle store these values in their respective variables and then printing the values on the screen. 


#include <stdio.h>

int main()

{

   int radius = 4;

   float PI=3.1415965,areacircumf;

   area PI radius radius;

   printf("\nArea of circle is: %f",area);

   circumf = PI * radius;

   printf("\nCircumference of circle is: %f",circumf);

   return(0);

}

OUTPUT


Area of circle is: 50.26548246
Circumference of circle is: 25.13274123

FLOWCHART

 PROGRAM:-

C program to find the area and circumference of a circle by taking the radius of a circle from the user.

#include <stdio.h>

int main()

{

   int radius;

   float PI=3.1415965,area, circumf;

   printf("\nEnter radius of circle: ");

   scanf("%d",&radius);

   area = PI * radius * radius;

   printf("\nArea of circle is: %f",area);

   circumf = 2 * PI * radius;

   printf("\nCircumference of circle is: %f",circumf);

   return(0);

}

OUTPUT


Enter radius of circle: 4

Area of circle is: 50.26548246
Circumference of circle is: 25.13274123
               

Post a Comment

1 Comments

  1. PI should be a constant and at least 3.1415965 in single precision! Otherwise, only output area & circumference as 3 sig figs (as in 3.14). Start with Good Practice and not add it on later! Enough said :)

    ReplyDelete