# 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 = πr^{2}

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() {
*double* radius, perimeter, area;
printf("Enter the radius: ");
scanf("%lf", &radius);
perimeter = 2*PI*radius;
area = PI*radius*radius;
printf("The perimeter is: %0.2lf\n", perimeter);
printf("The area is: %0.2lf\n", area);
return 0;
}

- 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.

- C program to print Integer & Decimal number given by user
- C Program to perform all arithmetic calculation
- C program to ask two numbers and find their sum
- C program to check a number is even, odd or zero
- C program to swap between two numbers
- C program to sum of natural numbers up to N
- C program to calculate the factorial of a number
- C program to make a multiplication table
- C program to calculate GCD of two numbers
- C program to calculate LCM of two numbers
- C program to count number of digits in a number
- C program to reverse a integer number
- C program to find the power of a number
- C program to check whether a number is palindrome or not
- C program to count and print prime numbers up to the N
- C program to check armstrong numbers
- C program to check armstrong numbers between two integers
- C program to find factors of a number
- C program to fined the size of all data types
- C program to print largest number among three numbers
- C program to check a number is positive or negetive
- C program to calculate the factorial of a number
- C program to form any kind of pyramid and stracture
- C program to find all the prime numbers between two numbers
- C program to check whether a number is prime or not
- C program to make a simple calculator
- C program to calculate the perimeter of a rectangle
- C program to calculate the area of a rectangle
- C program to calculate the diameter and area of a circle
- C program to convert kilometer to meter and centimeter
- C program to convert temperature celsius to fahrenheit
- C program to convert temperature fahrenheit to celsius
- C program to ask for days and convert into years, week and days
- C program to calculate the square root of a given number
- C program to find third angle of a triangle where two angles are given
- C program to calculate the area of a triangle
- C program to calculate area of an equilateral triangle
- C program to calculate average and percentage of result
- C program to calculate simple loan interest
- C program to compound loan interest
- C program to display fibonacci series of a number
- C program to swap two numbers without using third variable
- C program to print Hello World without using semicolon
- C program to insert assembly code and run it
- C program to printf Hello world without main() function
- C program to to calculate the multiplication of two matrix
- C program to convert decimal numbers into binary
- C program to form a triangle made with alphabet
- C program to form a triangle made with numbers
- C program to form a fibonacci triangle
- C program to convert a number into charecters

Happy Coding 🙂