Question: Create a file named loops.php . Put all of your code in loops.php . Loops Practice Exercises Part A ( for - loops ) Write
Create a file named loops.php Put all of your code in loops.php
Loops Practice Exercises
Part A forloops
Write six forloops that produce the following series of numbers. Your loops should print each series on the same line, with one or more spaces between each number as shown below. If you want to include the number at the start of each of these, use another variable. Then increment it add one to it and print it before your for loop code.
Part B whileloops
Write a collection of whileloops that solve the following problems. The steps for the first problem have been given to you:
Prompt the user to enter a positive integer n Print out all positive integers from to n
For example: n
Use the following steps to solve this problem:
Prompt the user to enter a positive integer, then store the result in an integer variable named n
Hint: Use a form that has no action or the action is loops.php this form posts to loops.php Add code to loops.php to check whether that the form element isset or exists. Use an if condition to decide whether to execute the while loop. Nest the while loop within an if block.
Declare an int variable called countWrite a while loop that uses your count variable to loop from to n what should your condition bePrint out count in your loop
Write a while loop that calculates and prints the sum of the first positive integers.
For example, calculating the following sum:
would print
Part C nested loops
Write a collection of nested loops that solve the following problems.
Display the following table of numbers in your web browser.
Draw the following rectangle on the console web browser
Draw the following rectangle on the console web browser
Challenge: draw the following shape on the console web browser
Put your code in a file named exactly: loops.php
Create a folder named loops. Put the file named, loops.php in your loops folder that is in your folder.
loopsloopsphp
Upload it to Chelan: studenthomeusernamepublichtmlloopsloopsphp
In your index.htm or index.html add a link to your file
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
