Write a program to compute the diameter in centimeters of a steel rod, an alumin
ID: 3635995 • Letter: W
Question
Write a program to compute the diameter in centimeters of a steel rod, an aluminum rod, and a copper rod, which can withstand a particular compression load. The allowable compression stress of steel, aluminum, and copper is 25,000 lbs/m^2, 15,000 lbs/m^2, 20,000 lbs/m^2, respectively.Area of rod = compression load / allowable compression stress
Area = ?r^2 where diameter d=2r
Input the compression load. Print the type of material, load, allowable stress, and diameter. Use formatted output with field width specifications that align the output.
Explanation / Answer
#include <stdio.h>
#include <math.h>
#define STEEL 25000
#define AL 15000
#define CP 20000
int main(){
int compLoad;
double ALdiam, STEELdiam, CPdiam;
scanf("%d", &compLoad);
ALdiam = (double)compLoad/(3.14*AL);
ALdiam = sqrt(ALdiam)*2;
STEELdiam = (double)compLoad/(3.14*STEEL);
STEELdiam = sqrt(STEELdiam)*2;
CPdiam = (double)compLoad/(3.14*CP);
CPdiam = sqrt(CPdiam)*2;
printf("Aluminium %d %d %l ", compLoad, AL, ALdiam);
printf("Steel %d %d %l ", compLoad, STEEL, STEELdiam);
printf("Copper %d %d %l ", compLoad, CP, CPdiam);
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.