a) Generate and display the following 10 numbers from the Fibonacci series using a do while loop and an if else statement inside the loop. {0} [1] [1] {2} [3] [5] {8} [13] [21] {34} [55] The series must be generated programmatically. \ Note that odd numbers and even numbers are displayed in [] and {} respectively. (10) (b) Write code that uses a while loop and an if else statement inside the loop to echo out the following: (10) Month 1 - Summer Month 2 - Summer ICT2613/103/0/2023 9 Month 3 - Autumn Month 4 - Autumn Month 5 - Autumn Month 6 - Winter Month 7 - Winter Month 8 - Winter Month 9 - Spring Month 10 - Spring Month 11 - Spring Month 12 - Summer (c) Write a switch statement in a function that will initialize the variable $result to the string 'Summer' for numbers 1, 2 and 12, 'Autumn' for numbers 3 to 5, 'Winter' for numbers 6 to 8, 'Spring' for numbers 9 to 11, and 'Unknown' for numbers other than 1 to 12. The switch statement must be coded with only 5 cases including the default case. Echo out the content of $result after the switch statement in the function. Invoke the function three times with values 3, 5, 10, 12 and 20
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
(a) Generate and display the following 10 numbers from the Fibonacci series using a do while
loop and an if else statement inside the loop.
{0} [1] [1] {2} [3] [5] {8} [13] [21] {34} [55]
The series must be generated programmatically. \ Note that
odd numbers and even numbers are displayed in [] and {} respectively. (10)
(b) Write code that uses a while loop and an if else statement inside the loop to echo out
the following: (10)
Month 1 - Summer
Month 2 - Summer
ICT2613/103/0/2023
9
Month 3 - Autumn
Month 4 - Autumn
Month 5 - Autumn
Month 6 - Winter
Month 7 - Winter
Month 8 - Winter
Month 9 - Spring
Month 10 - Spring
Month 11 - Spring
Month 12 - Summer
(c) Write a switch statement in a function that will initialize the variable $result to the string
'Summer' for numbers 1, 2 and 12, 'Autumn' for numbers 3 to 5, 'Winter' for numbers 6 to
8, 'Spring' for numbers 9 to 11, and 'Unknown' for numbers other than 1 to 12. The switch
statement must be coded with only 5 cases including the default case. Echo out the content of
$result after the switch statement in the function. Invoke the function three times with
values 3, 5, 10, 12 and 20
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)