C Program to Find Circumference of Circle

Howdy readers, today you will learn how to write a c program to find the circumference of a circle.

The circumference of a circle is the measure of the boundary of a circle.

The circumference of the circle is calculated using the circumference formula that needs the value of the radius of the circle and the value of PI which is a mathematical constant such that π = 22/7 or 3.14 (approx).

Circumference of Circle = 2πr

Where,

  • r is the radius of the circle
  • Π = 3.14

This program takes the radius of the circle from the user and then calculates the circumference of the circle using the circumference formula.

So, without further ado, let’s begin this tutorial.

C Program to Find Circumference of Circle

C Program

// C Program to Find Circumference of Circle
#include <stdio.h>

int main(){
    float radius;
    float CI, PI = 3.14;
    
    // Taking Input
    printf("Enter the radius of the circle: ");
    scanf("%f", &radius);
    
    // Calculating Circumference
    CI = 2 * PI * radius;
    
    // Display Circumference of Circle
    printf("Circumference of the circle is: %.2f", CI);
    
    return 0;
}

Output

Enter the radius of the circle: 7.2
Circumference of the circle is: 45.22
C Program to Find Circumference of Circle

Explanation

    float radius;
    float CI, PI = 3.14;

We have declared three float data type variables named radius CI and PI. The PI variable has been assigned a value of 3.14.

    printf("Enter the radius of the circle: ");
    scanf("%f", &radius);

Now, this program asks for input. The value of the radius entered by the user is taken using the scanf() function. The value gets stored in the radius variable.

    CI = 2 * PI * radius;

The circumference of the circle is computed with the help of circumference formula, circumference = 2πr.

In this program, we are using PI in place of π. So, our formula looks something like this: 

  • Circumference = 2 x PI x radius

The circumference obtained gets stored in the CI variable.

    printf("Circumference of the circle is: %.2f", CI);

After that, the circumference of the circle is displayed as output using the printf() function.

Conclusion

Today you learned how to write a C program to find the circumference of a circle.

Besides that, you have also learned about the circumference of a circle and the mathematical formula to calculate the circumference of a circle.

If you have any questions or issues regarding the program, comment down your queries in the comment section.

Thanks for reading.

Happy Coding!!

Also Read:

Leave a Comment