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 (for-loops)
Write six for-loops 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.
45678910
654321
246810121416
1917151311975
715233139
248163264
Part B (while-loops)
Write a collection of while-loops that solve the following problems. The steps for the first problem have been given to you:
1. Prompt the user to enter a positive integer n. Print out all positive integers from 1 to n.
For example:12345... 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 1 to n (what should your condition be?)Print out count in your loop
2. Write a while loop that calculates and prints the sum of the first 10 positive integers.
For example, calculating the following sum:
1+2+3+4+5+6+7+8+9+10,
would print 55.
Part C (nested loops)
1. Write a collection of nested loops that solve the following problems.
Display the following table of numbers in your web browser.
123456789
123456789
123456789
2. Draw the following rectangle on the console (web browser).
*****
*****
*****
*****
*****
3. 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 116 folder.
116\loops\loops.php
Upload it to Chelan: /studenthome/username/public_html/116/loops/loops.php
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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!