ECE 103 Engineering Programming Spring 2018 Secondary Exercise A (from MATLAB fo
ID: 2291812 • Letter: E
Question
ECE 103 Engineering Programming Spring 2018 Secondary Exercise A (from MATLAB for Engineers, 4th Edition, Holly Moore) a) Determine the volume (in cm) of the barbell, if the radius of each sphere is 8.5 cm, the length of the bar connecting them is 12 cm, and the diameter of the bar is 0.67 cm. Assume that the bar is a simple cylinder. b) Calculate the visible surface area (in cm2) of the barbell. Requirements Write a C program that solves the given problem. Define s macte for te e 3,1415924 Use variables with descriptive names to hold the given dimensional values. Display your calculated results to two (2) decimal places Save your program using this filename: hw2a.c Sample Output (actual numbers purposely hidden) Barbell volumeXXXX.xx cm3 Barbell area _xxx.xx?^2 XX cm*2Explanation / Answer
#include <stdio.h>
#include <conio.h>
#define PI 3.141592654
int main(){
float radius_bar, height_bar, Radius_sphere;
printf("Enter parameters of Barbell for Cylinder and sphere as radius_bar, height_bar, Radius_sphere: ");
scanf("%f %f", &radius_bar, &height_bar, &Radius_spehre);
/* Total surface area of Cylinder = 2 X PI X radius_bar X (radius_bar + height_bar) */
/* Surface area of Sphere = 4 x PI x (Radius_sphere)^3 */
surfaceArea_Barbell = floorf[{(2*PI*radius_bar*((radius_bar)+height_bar) + 2(4 *PI *(Radius_sphere^3)) - 2*PI *(radius_bar)^2)}*100]/100;
printf("Total surface area of Barbell : %0.4f ", surfaceArea_Barbell);
/* Volume of Cylinder = PI X Radius X Radius X Height */
Volume_Barbell = floorf[{PI*height_bar*radius_bar^2+ (4/3)*Radius_sphere^3}*100]/100;
printf("Volume of Cylinder : %0.4f ", volume);
getch();
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.