> Hello Can Someone please help me with this problem.
This is what i have sofar but i am not sure whats missing or how to end it please help.
A solid steel column of circular cross section is needed to support a load of 65,000 lb.
The ends of the column are not rigidly fixed but are able to rotate, and the point of 
application of the load may be as much as 1 in. from the axis of the column. 
The yield point of steel is 50,000 lb./in2, and the desired safety factor is 3. 
The column is 45 in. long. Determine the required diameter (up to four decimal places) 
to safely carry the load.

    where       


    s = (F *P) / A * ( L + ( ( e * c ) / ( i * i ) * ( 1.0 / cos ( ( L / ( 2.0 * i ) ) * sqrt (( F * P ) / ( A * E ) ) ) ) ))

    s   =   maximum stress  =   50,000 lb./ in2
                    F   =   factor of safety    =   3
                    P   =   applied load          = 65,000 lb.
                    A   =   cross section area  in2 =     for a circular column
                    e   =   eccentricity of applied load    =   1 in.
                    c   =   distance from column axis to extreme edge of cross section
                        =   d/2 for circular column
                    i   =   radius of gyration  =   d/4 for circular column
                    E   =   modulus of elasticity = 30,000,000 for steel
                    L   =   column length   =   45 in.






*


    #include "stdafx.h"
    #include <iostream>
    #include <iomanip>
    #include <cmath>
    using namespace std;

    int main () 

    {
    int F, P, e, E, L; 
    double pi = 3.14159;
    double d , c , i , A, s; 

    cout << "Enter Diameter" <<endl;
    cin >> d;
    do

    {
    F = 3;
    P = 65000; 
    e = 1;
    E = 30000000;
    L = 45;
    d = d + 0.01;
    c = d / 2.0;
    i = d / 4.0;
    A = ( pi * d * d ) / 4.0;
    s = (F *P) / A * ( L + ( ( e * c ) / ( i * i ) * ( 1.0 / cos ( ( L / ( 2.0 * i ) ) * sqrt (( F * P ) / ( A * E ) ) ) ) )); 

    }   while ( fabs ( 50000 - s) > 0.001 );

    cout << " Solution of diameter" << endl;
    cin >> s;



    } // end main

Could you tell us more about what you think is the problem with the code as given? By that I mean, is it not compiling, or running without completing, or completing but giving the wrong result? What are you supposed to return other than the computed diameter?

Nind you, I can see at least two major flaws in the program: first, it doesn't test to see if the input diameter is greater than the needed diameter, which could cause it to loop indefinitely; and second, the increment of the diameter is too large - it should be in the range of 0.001, which is the margin being tested for, not 0.01.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.