online business said this structure can help us write code to be simple,
The while structure provides a way to repetitively loop through a statement block.
The number of times the statement block is executed depends on the total times the
expression evaluates to true. The general form of the while loop is:
while (expression) :
statement block
endwhile;
Let's consider an example of the computation of n-factorial (n!), where n = 5:
$n = 5;
$ncopy = $n;
$factorial = 1; // set initial factorial value
while ($n > 0) :
$factorial = $n * $factorial;
$n-; // decrement $n by 1
endwhile;
print "The factorial of $ncopy is $factorial.";
how about for structure, online business said The for loop is simply an alternative means
for specifying the duration of iterative loops.
It differs from the while loop only in the fact that the iterative value is updated
in the statement itself instead of from somewhere in the statement block. As is the
case with the while loop, the looping will continue as long as the condition being
evaluated holds true. The general form of the for construct is:
for (initialization; condition; increment) {
statement block
}
This example illustrates the basic usage of the for loop:
for ($i = 10; $i <= 100; $i+=10) :
print "\$i = $i
"; // escaping backslash to suppress
// conversion of $i variable.
endfor;
which results in:
$i = 10
$i = 20
$i = 30
$i = 40
$i = 50
$i = 60
$i = 70
$i = 80
$i = 90
$i = 100
bookmark here
My Blog List
Blog Archive
Search Engine Optimization and SEO Tools
LinkAlizer makes it easy and fast for you to to find link exchange partners and increase traffic.
Subscribe to Business by Email
Duane Gartman - Seo Friendly Web Directory
Web Directory
SEO Master Iftekhar khan General Web Directory
Free Link Exchange Directory Submit Links
Submit Links To WahmD.Com Free Link Directory Submission Exchange Free web directory
Submit Links To WahmD.Com Free Link Directory Submission Exchange Free web directory
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment