For each of the problems below state the purpose in your own words, specify inpu
ID: 3585951 • Letter: F
Question
For each of the problems below state the purpose in your own words, specify input that is
needed, expected output, and the step by step process that will obtain the output from the input
(the algorithm).
Remember you are not to create actual code, but describe what should be done. For example, the
nested loop from the powerpoint could be described as the following:
• Create an outer loop that runs from 1 to 5
• Inside this outer loop output the variable name and the equal sign followed by the
value in the variable
• Have an inner loop that runs from 1 to the value of the variable for the outer loop.
• The inner loop should output the value in the variable of the variable for the inner
loop followed by a space.
• Once the inner loop has completed, out a new line and go to the next iteration of the
outer loop
Problem 2: Write a process that will ask the user to enter a number then output a pattern
consisting of user’s number of # in the first row, the user’s number -1 # in the second row, the
user’s number -2 # in the third row, etc. until the last row contains 1 #. For example if the user
entered 8, the pattern would be
########
#######
######
#####
####
###
##
#
Explanation / Answer
Algo:
1.) Enter the number:
2.) create an outer loop that runs from 1 to number (i.e., no. of rows)
3.) Have an inner loop, that runs from 1 to (number + 1 - value of the variable of outer loop)
4.) The inner loop should output the value ("#" in this case)for each iteration of inner loop followed by a space.
5.) Once the inner loop has completed, out a new line and go to the next iteration of the outer loop.
Hope it helps, do give your valuable response.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.