/*Stress and Strain in Steel Rods under Compression Loading */ /****************
ID: 3627141 • Letter: #
Question
/*Stress and Strain in Steel Rods under Compression Loading *//*************************************************************/
/* */
/* Defined constants */
/* PI - 3.141593 */
/* elast - 30000000 (lb/in^2) */
/* */
/* Input Variables */
/* diameter - diameter of the rod (inches) */
/* */
/* Working Variables */
/* load - amount of compression load from 10,000 lb/in^2 */
/* to 1,000,000 lb/in^2, with changes by 100,000 */
/* */
/* Computed Variables */
/* area - cross sectional area of the rod */
/* stress - compression stress (lb/in^2) */
/* strain - amount of strain on rod */
/* */
/* Output variables */
/* stress - amount of compression stress */
/* strain - amount of strain on diameter */
/* stress and strain will output at all values of load */
/* */
/*************************************************************/
#include <stdio.h>
double funcstress (double, double);
double funcstrain (double);
double funcoutput (double, double, double);
int main ( )
{
double stress, strain, diameter, load;
char press;
printf ("Input the diameter of the steel rod: ");
scanf_s ("%f, &diameter");
for (load = 10000; load <= 1000000; load +=100000)
{
stress = funcstress (diameter, load);
strain = funcstrain (stress);
funcoutput (load, stress, strain);
}
printf("Press any key to continue... ");
scanf_s("%d",&press);
return 0;
}
/*************************************************************/
/* Function to calculate the stress in the rod */
/*************************************************************/
/* */
/* Defined constants */
/* PI - 3.141593 */
/* */
/* Input Parameters */
/* diameter - diameter of the rod (inches) */
/* */
/* Local Variables */
/* stress - stress of the rod */
/* area - area of the rod */
/* pressure - amount of pressure from 10,000 lb/in^2 to */
/* 1,000,000 lb/in^2, with changes by 100,000 */
/* */
/* Computed Variables */
/* area - cross sectional area of the rod */
/* rodstress - compression stress (lb/in^2) */
/* */
/* Called by: Main */
/* */
/* Return variables */
/* rodstress - amount of compression stress */
/* stress will output at all values of Pressure */
/* */
/*************************************************************/
double funcstress (int load, float diameter)
{
const double PI = 3.141593;
double area, rodstress;
area = (PI * diameter * diameter) / 4;
rodstress = load / area;
return rodstress;
}
/*************************************************************/
/* Function to calculate strain in the rod */
/*************************************************************/
/* */
/* Defined constants */
/* elast - 30000000 (lb/in^2) */
/* */
/* Input Parameter */
/* stress - amount of stress on the rod */
/* */
/* Local Variables */
/* strain - amount of strain on the rod */
/* */
/* Computed Variables */
/* rodstrain - amount of strain on rod */
/* */
/* Called by: Main */
/* */
/* Output variables */
/* rodstrain - amount of strain on diameter */
/* stress and strain will output at all values of Pressure */
/* */
/*************************************************************/
float funcstrain (float stress)
{
const float elast = 30000000;
float rodstrain;
rodstrain = stress / elast;
return rodstrain;
}
/*************************************************************/
/* Function to ouput the results */
/*************************************************************/
/* */
/* Input Parameters */
/* rodstress - amount of stress on the rod */
/* rodstrain - amount of strain on the rod */
/* compload - amount of compression load */
/* */
/* Called by: Main */
/* */
/* Return Variable: NONE */
/*************************************************************/
void funcoutput (float load, stress, strain)
{
printf (" Stress at Loads: %f %f ", load, stress);
printf ("Strain: %f ", strain);
return;
}
Explanation / Answer
please rate - thanks
your prototypes and headers were all mixed up, the undefineds were because you were missing the type. I then fixed the rest of them
/*Stress and Strain in Steel Rods under Compression Loading */
/*************************************************************/
/* */
/* Defined constants */
/* PI - 3.141593 */
/* elast - 30000000 (lb/in^2) */
/* */
/* Input Variables */
/* diameter - diameter of the rod (inches) */
/* */
/* Working Variables */
/* load - amount of compression load from 10,000 lb/in^2 */
/* to 1,000,000 lb/in^2, with changes by 100,000 */
/* */
/* Computed Variables */
/* area - cross sectional area of the rod */
/* stress - compression stress (lb/in^2) */
/* strain - amount of strain on rod */
/* */
/* Output variables */
/* stress - amount of compression stress */
/* strain - amount of strain on diameter */
/* stress and strain will output at all values of load */
/* */
/*************************************************************/
#include <stdio.h>
double funcstress (double, double);
double funcstrain (double);
void funcoutput (double, double, double);
int main ( )
{
double stress, strain, diameter, load;
char press;
printf ("Input the diameter of the steel rod: ");
scanf_s ("%f, &diameter");
for (load = 10000; load <= 1000000; load +=100000)
{
stress = funcstress (diameter, load);
strain = funcstrain (stress);
funcoutput (load, stress, strain);
}
printf("Press any key to continue... ");
scanf_s("%d",&press);
return 0;
}
/*************************************************************/
/* Function to calculate the stress in the rod */
/*************************************************************/
/* */
/* Defined constants */
/* PI - 3.141593 */
/* */
/* Input Parameters */
/* diameter - diameter of the rod (inches) */
/* */
/* Local Variables */
/* stress - stress of the rod */
/* area - area of the rod */
/* pressure - amount of pressure from 10,000 lb/in^2 to */
/* 1,000,000 lb/in^2, with changes by 100,000 */
/* */
/* Computed Variables */
/* area - cross sectional area of the rod */
/* rodstress - compression stress (lb/in^2) */
/* */
/* Called by: Main */
/* */
/* Return variables */
/* rodstress - amount of compression stress */
/* stress will output at all values of Pressure */
/* */
/*************************************************************/
double funcstress (double load, double diameter)
{
const double PI = 3.141593;
double area, rodstress;
area = (PI * diameter * diameter) / 4;
rodstress = load / area;
return rodstress;
}
/*************************************************************/
/* Function to calculate strain in the rod */
/*************************************************************/
/* */
/* Defined constants */
/* elast - 30000000 (lb/in^2) */
/* */
/* Input Parameter */
/* stress - amount of stress on the rod */
/* */
/* Local Variables */
/* strain - amount of strain on the rod */
/* */
/* Computed Variables */
/* rodstrain - amount of strain on rod */
/* */
/* Called by: Main */
/* */
/* Output variables */
/* rodstrain - amount of strain on diameter */
/* stress and strain will output at all values of Pressure */
/* */
/*************************************************************/
double funcstrain (double stress)
{
const double elast = 30000000;
double rodstrain;
rodstrain = stress / elast;
return rodstrain;
}
/*************************************************************/
/* Function to ouput the results */
/*************************************************************/
/* */
/* Input Parameters */
/* rodstress - amount of stress on the rod */
/* rodstrain - amount of strain on the rod */
/* compload - amount of compression load */
/* */
/* Called by: Main */
/* */
/* Return Variable: NONE */
/*************************************************************/
void funcoutput (double load, double stress, double strain)
{
printf (" Stress at Loads: %f %f ", load, stress);
printf ("Strain: %f ", strain);
return;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.