Difference between revisions of "Convert this While to a For"
From CompSciWiki
Line 1: | Line 1: | ||
{{1010PrAD|ProblemName=Convert this While Loop to a For Loop | {{1010PrAD|ProblemName=Convert this While Loop to a For Loop | ||
− | |Problem= Almost any while loop can be converted into a for loop and vice versa. Take a look at the following sample program. Change it so that it uses a while loop instead of a for loop | + | |Problem= Almost any while loop can be converted into a for loop and vice versa. In fact, the for loop can be described as a while loop that iterates for a set number of times. Take a look at the following sample program. Change it so that it uses a while loop instead of a for loop. |
Revision as of 12:16, 6 April 2010
Back to the Program-A-Day homepage
ProblemAlmost any while loop can be converted into a for loop and vice versa. In fact, the for loop can be described as a while loop that iterates for a set number of times. Take a look at the following sample program. Change it so that it uses a while loop instead of a for loop. |
SideSectionTitle
An image or By Students section | |
---|---|---|
SolutionThe solution... | ||
CodeSolutionCode goes here. Please DO NOT put your code in <pre> tags! |