/////////////////////////////////// // // program_1 project // // created 8/12/21 by tj // rev 0 // /////////////////////////////////// // // Program to calculate sphere info // // Reads in a value for radius // prints the volume, greatest cross section // and greatest arc // // inputs: user input for R // outputs: prints 3 values // /////////////////////////////////// #include "mbed.h" #include // only needed when printing #define PI 3.14159 int main(void){ setbuf(stdout, NULL); // disable buffering when printing // splash printf("\n\nprogram_1\n"); printf("Using Mbed OS version %d.%d.%d\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); printf("Welcome to my sphere program\n"); // put all the variable declarations upfront float r; float volume; float area; float arc; // ask for and read in radius printf("Please enter a value for the radius in cm: "); scanf("%f", &r); // calculate all 3 values volume = 4.0/3.0 * PI * r * r * r; area = PI * r * r; arc = 2 * PI * r; // print results printf("The volume of the sphere is %f cm cubed\n", volume); printf("The greatest cross section is %f cm squared\n", area); printf("The greatest arc length is %f cm\n", arc); return 0; }// end main