Problem 10.1 (Using Arrays) Draw the FLOW CHART and write a C code program THAT
ID: 3737567 • Letter: P
Question
Problem 10.1 (Using Arrays) Draw the FLOW CHART and write a C code program THAT USES ARRAYS to calculate the shear and moment at every foot on a 20-foot long uniformly loaded beam. Produce an output table as shown below. Include a decision structure in the loop structure to print a message if the maximum moment (m_max) is higher than the maximum allowable moment (m_allow) and print a message indicating this. Inside the loop, include a decision structure to determine the maximum moment (mmax) along with the distance (x) at which this maximum moment occurs on the beam. Indicate the value of the maximum moment (mmax) and where it is located (x). Outside the loop, include a decision structure to determine if the beam is safe and print a message indicating safe or unsafe. Input data: w - load (user input) L - length (define as 30) M_ALLOW(define as 5000) distance - value of x at m_max Equations: v = w L/2 - w x m = w L x / 2 - w x2 / 2 Output data: x[L+1] - distance array v[L+1] - shear array m[L+1] - moment array m_max - maximum moment OUTPUT SHOULD APPEAR AS FOLLOWS: Enter the uniformly distributed weight in lb./ft.>>40 Weight is 40.00 lb/ft. Length is 30.00 ft. DISTANCE SHEAR MOMENT (x ~ ft.) (V ~ lbs.) (M ~ ft-lb) ____________________________________________________ 0 600 0 1 560 580 2 520 1120 ... 14 40 4480 15 0 4500 16 -40 4480 ... 29 -560 580 30 -600 Beam is safe, allowable moment is 5000 ft-lb. Maximum moment 2000 ft-lb is at x = 15 ft. 0 I did the C code; I want this problem repeated in Matlab. Thank you.
Explanation / Answer
At the very first step we need to analyze the beam as under :
# include <stdio.h>
# include <conio.h>
# include <math.h>
int cur1=0, cur2=0, cur3=0, cur4=0, no, j;
float con[25][2], udl[25][3], lvl[25][4], moc[25][3], result[100][3], len_spa, int_val;
(Here con defines Concentrated loads/ udl defines uniformly distributed loads/lvl defines linearly varrying loads/moc dfines concentrated moment)
float sf_con ( float con[25][2], float len_spa, float x);
float sf_udl ( float udl[25][3], float len_spa, float x);
float sf_lvl ( float lvl[25][4], float len_spa, float x);
float sf_moc ( float moc[25][3], float len_spa);
float bm_con ( float con[25][2], float len_spa, float x);
float bm_udl ( float udl[25][3], float len_spa, float x);
float bm_lvl ( float lvl[25][4], float len_spa, float x);
float bm_moc ( float moc[25][3], float len_spa, float x);
float to_sf ( float x);
float to_bm ( float x);
float bisection ( float result[100][3], int j);
In order to stand with the basic instructions of the program we need to follow these codes :
printf(" Concentrated Load = 'c' or 'C'.");
printf(" Uniformly Distributed Load = 'u' or 'U'.");
printf(" Linearly Varying Load = 'l' or 'L'.");
printf(" Concentrated Moment = 'm' or 'M'.");
printf(" Sign Conventions :- ");
printf(" ----------------");
printf(" Shear Force = '+ ve' for Upwards Load to the left of section.");
printf(" Bending Moment = '+ ve' for sagging.");
printf(" Clockwise Couple = '1'.");
printf(" Anticlockwise Couple = '-1'.");
printf(" Units :- ");
printf(" -----");
printf(" Load = KNS. Distance = Meters.");
printf(" Please Enter the data and proceed.");
(Here is used for the new line to get the output arranged in well behaved manner)
printf(" Please mention the Length of Beam = "); // we can enter 30, as desired length is 30
scanf("%f", &len_spa);
printf(" Enter the number of points to see S.F. and B.M. = ");
scanf("%d", &no);
int_val = len_spa / (no-1);
Decision structure starts :
do
{
printf(" Loading type = ");
fflush(stdin);
scanf("%c", &loa_typ);
if ((loa_typ == 'c') || (loa_typ == 'C'))
{
printf(" Mention the concentrated loads = ");
scanf("%d", &co);
for ( i = cur1 ; i < ( cur1 + co ) ; i++ )
{
printf(" Intensity of Load %d = ",i+1);
scanf("%f", &con[i][0]);
printf(" Distance of Load %d from left= ",i+1);
scanf("%f", &con[i][1]);
}
cur1 = cur1 + co;
printf(" Require more Loads ( Y/N ) = ");
fflush(stdin);
scanf("%c", &choice);
}
else if ((loa_typ == 'u') || (loa_typ == 'U'))
{
printf(" Number of UDL = ");
scanf("%d", &ud);
for ( i = cur2 ; i < ( cur2 + ud ) ; i++ )
{
printf(" Intensity load %d (KN/M) = ",i+1);
scanf("%f", &udl[i][0]);
printf(" Initial point of Load %d from Left Support = ",i+1);
scanf("%f", &udl[i][1]);
printf("Final Point of Load %d from Left Support = ",i+1);
scanf("%f", &udl[i][2]);
}
cur2 = cur2 + ud;
printf(" Require more Loads ( Y/N ) = ");
fflush(stdin);
scanf("%c", &choice);
}
else if ((loa_typ == 'l') || (loa_typ == 'L'))
{
printf(" Require number of Linearly Varying Loads = ");
scanf("%d", &lv);
for ( i = cur3 ; i < ( cur3 + lv ) ; i++ )
{
printf(" nIntensity load %d at Starting Point (KN/M) = ",i+1);
scanf("%f", &lvl[i][0]);
printf(" Intensity of Load %d at Ending Point (KN/M) = ",i+1);
scanf("%f", &lvl[i][1]);
printf("Dis. from Initial Point of Load %d from Left Support = ",i+1);
scanf("%f", &lvl[i][2]);
printf(" Dist. To final Point of Load %d from Left Support = ",i+1);
scanf("%f", &lvl[i][3]);
}
cur3 = cur3 + lv;
printf(" Require more Loads ( Y/N ) = ");
fflush(stdin);
scanf("%c", &choice);
}
else if ((loa_typ == 'm') || (loa_typ == 'M'))
{
printf(" Concentrated Moments = ");
scanf("%d", &mo);
for ( i = cur4 ; i < ( cur4 + mo ) ; i++ )
{
printf(" Magnitude of Moment %d = ",i+1);
scanf("%f", &moc[i][0]);
printf("Distance of Moment %d from Left Support = ",i+1);
scanf("%f", &moc[i][1]);
printf("Direction to which Moment %d is acting ( 1 or -1 ) = ",i+1);
scanf("%f", &moc[i][2]);
}
cur4 = cur4 + mo;
printf(" Require more Loads ( Y/N ) = ");
fflush(stdin);
scanf("%c", &choice);
}
else
{
printf(" Abbreviations referred."); // To assure if the abbreviations mentioned at the very starting of the program is being preferred correctly or not
printf(" Continue ? ( Y/N ) = ");
fflush(stdin);
scanf("%c", &choice);
}
}
while ((choice == 'y') || (choice == 'Y'));
//clrscr();
Bisection method to observe Maximum Bending
x = bisection ( result, j);
max_bm = to_bm ( x );
printf(" Max. BM is %0.3f is occur at %0.3f M distance from Left Support.",max_bm,x);
getch();
return 0;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.