Let’s take a look at how to calculate the circumference of the circle in C Programming. We are referring to an awesome book called “Let Us C” by “Yashwant Kanetkar“. Hence, please come back to our portal regularly so that you don’t miss anything. If you have any problems with the program or need any assistance, don’t hesitate to write to us. We try to answer as quickly as possible.
Question:
Accept the values of radius of the circle and write a program to calculate the circumference.
Solution to calculate the circumference of circle in C:
Calculating the circumference of a circle in C is super easy. All you need to know is the formula and just like any other math program you can calculate the circumference. Here’s the algorithm:
- Input the radius of the circle from the user.
- Calculate the circumference using the formula – 2*pi*r
- Output the circle’s circumference
Here, we first initialise all the variables and set the value of pi to 3.14. Make sure that all the values are of the floating datatype or you won’t get accurate results. Then, ask the user to input the radius of the circle. Then use the math operators to calculate the result and display the output back to the user.
Download the source code:
Download ProgramProgram to calculate the circumference of the circle in C:
//C Program to calculate the circumference of a circle #include<stdio.h> #include<conio.h> void main() { float pi = 3.14, circumference; float radius; clrscr(); printf("Enter the radius of the circle - ") ; scanf("%d",&radius); circumference = 2*pi*radius; printf("The circumference of the circle is %f ",circumference); getch(); }
Output
Enter the radius of the circle: 30
The circumference of the circle is 188.5
Download the source code:
Please don’t forget to subscribe to us before you hit the download button! It helps us grow and provide more content.
Download ProgramRead Also:
Check if the number is Odd or Even in C
Calculate the volume of a Cylinder in C