Untitled
unknown
c_cpp
2 years ago
936 B
6
Indexable
#include <stdio.h>
// Function to calculate the area of the green field
double calculateGreenArea(double length, double width, double redDiameter) {
double radius = redDiameter / 2;
double greenLength = length - redDiameter;
double greenWidth = width;
double greenArea = greenLength * greenWidth;
return greenArea;
}
int main() {
double length, width, redDiameter;
// Input length, width, and red circle diameter
printf("Enter length of the flag: ");
scanf("%lf", &length);
printf("Enter width of the flag: ");
scanf("%lf", &width);
printf("Enter diameter of the red circle: ");
scanf("%lf", &redDiameter);
// Calculate green field area
double greenArea = calculateGreenArea(length, width, redDiameter);
// Output the result
printf("The area of the green field on the flag is: %.2lf square units\n", greenArea);
return 0;
}Editor is loading...
Leave a Comment