Write a main function, and the following functions to compute the stress and str
ID: 2121863 • Letter: W
Question
Write a main function, and the following functions to compute the stress and strain oa a steel rod(D) (in inches) and length(L) in inches subject to the compression load(P) of 10,000 to 1,000,000 pounds in increments of 100,000 pounds. The modulus of elasticity (E) for steel is 30 x 10^6.
function to compute the stress formula:
stress f = P/A
where A =%u03C0D2/4.0
A function to compute the strain from the formulas:
elongated or shortened length:
%u0394 L = fL/E
strain e = %u0394 l/l = f/E
A function to output the stress and strain at different loads of P
The function should call each other as Main(top), Calulate stress(1), Calculate strain (2) and output (3)
current answers do no work in C program, I have basically the same answers but I keep getting that my declarations are(were here before) print screen shows up but only "press any key to continue". Thanks
Explanation / Answer
#include<stdio.h>
#include <math.h>
float compute_stress();
float compute_strain(float);
void output_results(float,float);
int main( )
{
float strs,strn;
clrscr();
strs=compute_stress ();
strn= compute_strain (strs);
output_results(strs,strn);
return(0);
}
float compute_stress()
{
const float PI = 3.141593;
float stress, diam , area;
long int p;
stress=0;
printf(" Enter diameter: ");
scanf("%f", &diam);
area=(PI * (diam *diam ))/4;
for(p=10000; p<=100000000; p= p+100000)
{
stress = stress+(p/area);
}
return stress;
}
float compute_strain(float stress)
{
const float e=30000000;
float strain;
strain = stress/e;
return strain;
}
void output_results (float stress, float strain)
{
printf(" Stress = %f Strain = %f",stress, strain);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.