C Program to Calculate Area, Diameter and Circumference of Circle

In this source code example, we will a C Program to accept radius & calculate area, diameter and 
circumference of a circle.

C Program to Calculate Area, Diameter, and Circumference of Circle

In this C program, we will take input from the User or console and print the result to the output: 
#include<stdio.h>
main() {
     /*Declare the variables*/
     int radius,diameter;
     float area,circumference;
     const float PI = 3.14; /*set variable PI to constant*/
     /*Accept the value of radius*/
     printf("Enter circle radius: ");
     scanf("%d",&radius);
     /*Compute the area, diameter and circumference*/
     diameter = 2*radius;
     area = PI*radius*radius;
     circumference = 2*PI*radius;
     /*Display the results*/
     printf("Area of circle = %.2f",area);
     printf("\nDiameter of circle = %d",diameter);
     printf("\nCircumference of circle = %.2f",circumference);
}


Output:

Enter circle radius: 10
Area of circle = 314.00
Diameter of circle = 20
Circumference of circle = 62.80




Comments