Untitled
unknown
plain_text
10 months ago
754 B
4
Indexable
#include <stdio.h>
#include <math.h>
#define PI 3.14159
int main() {
float radius, diameter, circumferenceCircle, surfaceAreaSphere, volumeSphere;
// Input the radius
printf("Enter the radius: ");
scanf("%f", &radius);
// Calculations
diameter = 2 * radius;
circumferenceCircle = 2 * PI * radius;
surfaceAreaSphere = 4 * PI * radius * radius;
volumeSphere = (4.0f / 3.0f) * PI * radius * radius * radius;
// Output the results
printf("\nFor a Circle:\n");
printf("Diameter: %.2f\n", diameter);
printf("Circumference: %.2f\n", circumferenceCircle);
printf("\nFor a Sphere:\n");
printf("Surface Area: %.2f\n", surfaceAreaSphere);
printf("Volume: %.2f\n", volumeSphere);
return 0;
}Editor is loading...
Leave a Comment