While the output of the simpleFor.phpprogram doesn t look

September 29, 2006 on 11:35 pm | In php |

LoopsandArrays$i = 0; It specifies that the sentry variable be called $iand its starting value be 0. Computer programs frequently begin counting with zero, so I initialized $ito 0as well. Although the $i = 0;segment looks like (and is) a complete line of code, it isusually placed on the same line as the other parts of the forloop construct. Setting a Condition to Finish the LoopGetting a computer to repeat behavior is the easy part. The harder task comeswhen trying to get the computer to stop correctly. The second part of the forloopconstruct is a condition. When this condition is evaluated as TRUE, the loop shouldcontinue. The loop should exit as soon as the condition is evaluated to FALSE. Inthis case, I set the condition as $i < 10. This means that as long as the variable $ihas a value less than 10, the loop continues. As soon as the program detects that$ihas a value equal to or larger than 10, the loop exits. Usually a forloop s con- dition checks the sentry variable against some terminal or ending value. Changing the Sentry VariableThe final critical element of a forloop is some mechanism for changing thevalue of the sentry variable. At some point the value of $imust become 10orTRICKINTHEREALWORLDYou might wonder why the sentry variable is called $i. Like most variables, it s best if sentry variables have a name that suits their purpose. Sometimes, however, a forloop sentry is simply an integer and doesn t have any other mean- ing. In those situations, an old programming tradition is often called into play. In the Fortran language (one of the earliest common programming languages), all integer variables had to begin with the letters i, j,and a few other characters. Fortran programmers would commonly use ias the name of generic sentry variables. Even though most modern programmers have never written a line ofFortran code, the tradition remains. It s amazing how much folklore exists insuch a relatively new activity as computer programming.
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services

WordPress database error: [Table './sandzak_com_-_blog/wp_comments' is marked as crashed and should be repaired]
SELECT * FROM wp_comments WHERE comment_post_ID = '180' AND comment_approved = '1' ORDER BY comment_date

No Comments yet

TrackBack URI

Sorry, the comment form is closed at this time.

Powered by cheap hosting