Lab #7 - Task 6
Stephan Knotek
Task 6 - for Loop
In a for loop you initialize the counter, evaluate the condition, and increment the counter. Oftentimes you will see this as for ($i = 0; $i <10; $i++) where $i becomes kind of a generic variable for a number. In this task we’re going to work with leap years.
- In the for loop initialize the counter by giving a starting value of "2020."
- Then evaluate the condition by testing whether the leap year variable is less than 2055. We're going to present all of the leap years between 2020 and 2055.
- Then increment the counter. Remember that leap years happen every four years, so that is how you should increment it. You may want to take a look at W3Schools.com for more guidance.
- Inside the for loop, create a statement to display each of the leap years. Be sure to include the statements in a paragraph that will display "Year (it will display the year) is a leap year." Add a line break or horizontal rule to separate the lines.
(Hint: Be sure to wrap the line you are displaying in paragraph tags, or use a line break or horizontal rule at the end of each line or everything will run together.)
Year 2020 is a leap year.
Year 2024 is a leap year.
Year 2028 is a leap year.
Year 2032 is a leap year.
Year 2036 is a leap year.
Year 2040 is a leap year.
Year 2044 is a leap year.
Year 2048 is a leap year.
Year 2052 is a leap year.