Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 months ago
995 B
8
Indexable
Never
#include <stdio.h>

// Calculate the area of the green portion
double calculateGreenPortionArea(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
    printf("Enter length of the flag: ");
    scanf("%lf", &length);
    
    // Input width
    printf("Enter width of the flag: ");
    scanf("%lf", &width);
    
    // Input red circle diameter
    printf("Enter diameter of the red circle: ");
    scanf("%lf", &redDiameter);

    // Calculate area of the green portion
    double greenPortionArea = calculateGreenPortionArea(length, width, redDiameter);

    // Output the result
    printf("The area of the green portion on the flag is: %.2lf square units\n", greenPortionArea);

    return 0;
}
Leave a Comment