C Program to find diameter, circumference and area of a circle

Category: C Program

Write a C program to enter the radius of a rectangle and find the diameter, circumference and area of a circle.

Formula to find diameter, circumference and area of circle

DIAMETER = 2 * RADIUS
CIRCUMFERENCE = 2 * π * RADIUS
AREA = π * RADIUS * RADIUS

And we can use operators to implement the same formula in our C program.

Example -

Input: Enter radius of the circle: 7
Output: Diameter of circle: 14.000000
Circumference of circle: 43.959999
Area of circle: 153.860001

C program to find diameter, circumference and area of a circle

#include <stdio.h>
#define PI 3.14

void main()
{
    float radius, diameter, area, circumference;

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

    diameter = 2 * radius;
    circumference = 2 * PI * radius;
    area = PI * radius * radius;

    printf("Diameter of circle: %f\n", diameter);
    printf("Circumference of circle: %f\n", circumference);
    printf("Area of circle: %f", area);
}

Output

Enter radius of the circle: 7
Diameter of circle: 14.000000
Circumference of circle: 43.959999
Area of circle: 153.860001

Recommended Posts