|
|
![]() | Syntax: for ( InitStatement ; Expression1 ; Expression2 ) Statement |
![]() | InitStatement, Expression1, and Expression2 are
optional.
|
![]() | Semantics: The for loop comes close to following
while construct:
{ |
![]() | Layout according to our coding standard:
for ( InitStatement; Expression1; Expression2 ) { |
| Factorial.java |
// compute n!
factorial = 1;
for (int i = 1; i <= n; ++i) {
factorial *= i;
}
|
|
| Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 11, 2002 |