In this example, We are going to find area of circle. So firstly we should know formula for calculating Area of any Circle;
Circle Area is the multiplication of square of radius and PI . Where PI is a constant which value is 3.14.
C Program to Find Area of Circle
#include<stdio.h>
#define PI 3.14
void main()
{
float radius, area;
printf("Enter value of Radius");
scanf("%f",&radius);
area = radius * radius * PI;
printf("Area of the Circle = %.2f",area);
}
Output
Enter value of Radius
9
Area of the circle = 254.34
Explanation
In this program, We calculated area of the Circle using c program. For this we have define a constant “PI” using preprocessor (#).
Introduction of C and Hello World Program
C program to Addition of two numbers
C program to find Area of Triangle