0

Greetings Team:

This code looks pretty decent. The program runs but it is incomplete. I need help making the program below work better. I did a MAIN function and the following funcations to compute the stress and strain in a steel rod of diameter D (inches) and length L (inches) subject to the compress loads 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 to the 6th power.

Any help would be greatly appreciated.

Best,

Dani

```
#include<stdio.h>
#include <math.h>
float compute_stress();
float compute_strain(float);
void output_results(float,float);
int main( )
{
float strs,strn;
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("\n\tEnter 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("\n\tStress = %f \n\tStrain = %f",stress, strain);
}
```

*Edited 1 Year Ago by daniel1977*