#include <stdio.h>
typedef struct {
char name[20];
int numberOfEdges;
float radius;
float area;
} twoDShape;
int main() {
twoDShape shapeList[10];
twoDShape *shapePtr;
shapePtr = shapeList;
for (int i = 0; i < 10; i++) {
printf("Enter name of shape: ");
scanf("%s", shapePtr->name);
printf("Enter number of edges (or -1 for a circle): ");
scanf("%d", &shapePtr->numberOfEdges);
if (shapePtr->numberOfEdges == -1) {
printf("Enter radius of circle: ");
scanf("%f", &shapePtr->radius);
shapePtr->area = 3.14159 * (shapePtr->radius * shapePtr->radius);
} else if (shapePtr->numberOfEdges == 3) {
float h, b;
printf("Enter value of height: ");
scanf("%f", &h);
printf("Enter value of base: ");
scanf("%f", &b);
shapePtr->area = (h * b) / 2;
} else if (shapePtr->numberOfEdges == 4) {
float l;
printf("Enter value of length: ");
scanf("%f", &l);
shapePtr->area = l * l;
}
shapePtr++;
}
shapePtr = shapeList;
for (int i = 0; i < 10; i++) {
printf("Shape: %s\\", shapePtr->name);
printf("Number of edges: %d\\", shapePtr->numberOfEdges);
printf("Area: %f\\", shapePtr->area);
shapePtr++;
}
return 0;
}