Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple While Loop 1

Status
Not open for further replies.

chrismoore2

Mechanical
Dec 9, 2011
12
0
0
US
I have been beating my head against a wall on something so simple. Will someone put me out of my misery please

Attached is the simple sheet. Please tell me where I am going so wrong.
 
Replies continue below

Recommended for you

Well, now I am home and dont have the file.

SS: |h <-- 1
|b <-- 1
|Sa < -- b + h
| while Sa ≤ 10
| h <-- h + 1
|return h

the program says basically i have an infinite loop. dont get it
I have done it without the return statement as well and get the same answer. I should get ss = 9

any ideas?
 
It seems that your loop increases h, but does not calculate Sa in the loop... My guess is that you should put Sa <-- b+h in the while loop, and then the loop will not be infinite. HTH
 
Tried changing the inequality sign

SS: |h <-- 1
|b <-- 1
| while Sa < 10
|Sa < -- b + h
|h <-- h + 1
|return h

ss = 10

still should be 9
 
Look at the help for the While command. While goes until condition is met. If you are looking for a specific number of loops use the For loop command. It seems the While command start counting from zero and not from one.
 
yea, did that, and all the other internet searches I could, to no avail. The while command can start from any point, and I have no idea how many iterations it will take to get to my result, hense the reason for using the while loop
 
I have ver. 13, so I couldn't load your .xmcd file, but from the .pdf file, it seems that you don't define Sa before the while loop, so it never is > 25ksi and h stays at 5 mm.
 
Status
Not open for further replies.
Back
Top