-
For Loop Problems
I am creating a program that calculates the beam sized needed for a certain load based on three given equation. I need to automate the selection of beam width. Which means I have to run the functions until they pass the test. I am incrementing the width by 2.(2x2 4x4....) I want my For loop to run until the if test is true and the variable test=1 and print out the statement. Right Now it seems like I can't even enter the for loop, I am only prompted for the length and load then nothing happens. I can't seem to figure out why, any suggestions would be great. I attached the source file.
-
.
Code:
for(width=2;test=1;width+=2)
{ loadb=buck(length,width);
loadc=comp(width);
result=slender(length,width);
if(loadb<=load && loadc<=load && result==1)
{cout<<"For a load of "<<load<<" and a length of "<<length<<" inches,recommended sqaure beam has a side of "<<width<<" inches\n";
test=1;}
else
test=0;
}
it should be ==
but i dont like it anyhow, why dont you use a while loop instead?
while(test)
-
I didn't like it much either, used a while loop instead, much easier. Thank you