HW17_Tierra_Dean.pdf - CIT120-19Z3 Page 1 of 10 Homework#17 Name Homework 17 Chapter 5 1 Chapter 5"Programming Exercises 1b What is the output of the

# HW17_Tierra_Dean.pdf - CIT120-19Z3 Page 1 of 10 Homework#17...

• 10

This preview shows page 1 - 4 out of 10 pages.

CIT120-19Z3 Homework #17 Page 1 of 10 Name: ______________ Homework 17 Chapter 5 1. Chapter 5 "Programming Exercises" 1b: What is the output of the following pseudocode? [Show your work and clearly identify the output] d = 4 e = 6 f = 7 while d > f d = d + 1 e = e 1 endwhile output d,e,f The variable d is initialized to 4. e is initialized to 6 and f is initialized to 7. The while loop first checks whether the expression is true or not. Here is the d is not greater than the value of f, which means 4 is not greater than 7. Therefore, the loop will not execute. output (4,6,7) 2. Chapter 5 "Programming Exercises" 1d: What is the output of the following pseudocode? [Show your work and clearly identify the output] j = 2 k = 5 n = 9 while j < k m = 6 while m < n output "Goodbye" m = m + 1 endwhile j = j + 1 endwhile The variable j is initialized to 2. k is initialized to 5 and n is initialized to 9. The outer while loop will run until the value of j is less then the value of k. The variable m is initialized to 6. The inner while loop runs until the value of m is less than the value of n. The pseudocode segment displays the Goodbye . The value of m is incremented by 1. The value of j is incremented by 1. Therefore, the outer while loop will run for 3 times and the inner while loop will also run for 3 times. The pseudocode segment displays the Goodbye nine times on the screen.
CIT120-19Z3 Homework #17 Page 2 of 10 Name: ______________ output Goodbye Goodbye Goodbye Goodbye Goodbye Goodbye Goodbye Goodbye Goodbye 3. Design the logic of a program that outputs numbers in reverse order from 25 down to 0. start declarations num number housekeeping() while number >= 0 detailLoop() endwhile endOfJob() stop housekeeping() number = 25 return detailLoop() output number number = number 1 return endOfJob() output “End of program” return start num number number = 25
CIT120-19Z3 Homework #17 Page 3 of 10 Name: ______________ 4. Design the logic of a program that outputs all the numbers that are divisible by 3 from 0 to 100 (inclusive).

#### You've reached the end of your free preview.

Want to read all 10 pages?

• Fall '17
• James Kolasa

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern