Write a C program to find the area of a semicircle. This example allows entering the semicircle radius and uses it to calculate the area.
- Perimeter = 3.14 * radius
- Area = 1/2πr²
#include <stdio.h> int main() { float clRadius, clArea, clPerimeter; printf("Enter the Semicircle Radius = "); scanf("%f",&clRadius); clPerimeter = 3.14 * clRadius; clArea = 0.5 * 3.14 * (clRadius * clRadius); printf("The Perimeter of a Semicircle = %.2f\n", clPerimeter); printf("The Area of a Semicircle = %.2f\n", clArea); return 0; }
In this program, circleArea and circlePerimeter functions accept radius and find the perimeter and area of a semicircle.
#include <stdio.h> float circleArea(float clRadius) { return 0.5 * 3.14 * (clRadius * clRadius); } float circlePerimeter(float clRadius) { return 3.14 * clRadius; } int main() { float clRadius, clArea, clPerimeter; printf("Enter the Radius = "); scanf("%f",&clRadius); clPerimeter = circlePerimeter(clRadius); clArea = circleArea(clRadius); printf("The Perimeter = %.2f\n", clPerimeter); printf("The Area = %.2f\n", clArea); return 0; }
Enter the Radius = 12
The Perimeter = 37.68
The Area = 226.08