# C program to find the area and perimeter of a circle

In this tutorial, we will learn, how to find the area and perimeter of a circle. We know the formulas for calculating the perimeter and area of a circle.

For the circles;
Perimeter = 2πr
Area = πr2

From both formulas, we see all the parameters are constant excluding r (radius). So we need one parameter as an input and then we can find the area and perimeter.

So to write the specified program, we will need the two above mathematical formulas and some basic concepts of the C programming language.

## Algorithm – Finding area and perimeter of a circle

• We will calculate all the things in the main function. Additional functions are not required but you can write if you want.
• Define the PI constant value of 3.1416 using the #define directive.
• Inside the main function, declare three variables radius, perimeter, and area. Make sure all the variable types are double. It will allow taking input of decimal number (floating point).
• Ask for the radius of the circle using the scanf() function and keep it in the radius variable.
• Perform the arithmetic calculation for finding perimeter and keep the result in the perimeter variable.
• In the next expression, perform the arithmetic calculation for finding the area and keep the result in the area variable.
• Finally, print out the results using the print() function.

## C Program to Find area and perimeter of a circle

``````#include <stdio.h>
#define PI 3.1416
int main() {

printf("The perimeter is: %0.2lf\n", perimeter);
printf("The area is: %0.2lf\n", area);

return 0;
}``````
1. Now save the file with a .c extension and run the program using your favorite IDE. You will get output something like the below:
Sample Input Sample Output
Enter the radius: 7 The perimeter is: 43.98 The area is: 153.94
Enter the radius: 5.76 The perimeter is: 36.19 The area is: 104.23

## General Learning Output (GLO)

• Formulas for finding the area and perimeter of a circle.
• Defining constants in C using the #define directive.
• Declaring multiple same types of variables in one statement.
• Uses of double data type in C programming language.
• The syntax of scanning/taking input from the users.
• Scanning double number in the scanf() function.
• Performing arithmetic operations and keeping the results in a variable.
• Printing the values of variables using printf() function.

Happy Coding 🙂