C program to calculate area of a circle.
In this example we will learn to calculate the area of a circle. Here in this program we will use 3.14 as the value of pi.
- The formula to calculate the area of a circle is:
area= π r²
Flowchart To Calculate the Area of a Circle:
PROGRAM:
#include<conio.h>
#include<stdio.h>
int main()
{
float radius,area;
printf("Enter the radius of the circle : ");
scanf("%f",&radius);
area=3.14*radius*radius;
printf("Area of the circle is : %.2f",area);
return 0;
}
OUTPUT:
C program to calculate area of a circle using function.
Here, we will learn how to calculate the area of a circle using function.
Program:
#include<conio.h>
#include<stdio.h>
float circle(float);
int main()
{
float radius,area;
printf("Enter the radius of the circle : ");
scanf("%f",&radius);
circle(radius);
return 0;
}
float circle(float r)
{
float area;
area=3.14*r*r;
printf("Area of the circle is : %.2f\",area);
}
Output:
NOTE:
You Can post your code in our comment section. Your comment will be approved if your code is different from the code posted above. Thank You.
MOTTO: You Learn, I Learn Together We Learn
Comments
Post a Comment
Please do not spam any link