C Programming Examples Tutorial Index

C Number Programs

This C example program performs simple mathematical calculations to find the area and perimeter of a circle. The perimeter of a circle is equal to 2*PI*Radious, and its area equals to PI*Radius2. Here PI refers to the value of pi(π).

Example C Program:
#include <stdio.h>

#define PI 3.14f /* Define the value of pie */

void main() {
  /* Variable Declaration. */
  float radius, perimeter, area;

  /* Taking input of the radious of the circle from the user */
  printf("Enter radius of the Circle:\n");
  scanf("%f", & radius);

  /* Calculating perimeter of the circle */
  perimeter = 2 * PI * radius;
  printf("Perimeter of the circle: %0.4f\n", perimeter);

  /* Calculating area of the circle */
  area = PI * radius * radius;
  printf("Area of circle: %0.4f\n", area);

Program Output:

Enter radius of the Circle:
Perimeter of the circle: 125.6000
Area of circle: 1256.0000

Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram