
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Introduction to Computer Programming; Subject: Computational Science; University: Syracuse University; Term: Unknown 1989;
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Homework 2 Review:
Program Steps for the 99 Bottles Program:
Version 1: prints the last n verses
Get the number of verses from the user Loop over the verses with the index ranging from the user’s number down to 1, decrementing by 1 if it’s not the last verse, Print the verse corresponding to the loop index, using index and index - else it is the last verse, Print the special last verse using 1.
Version 2: prints the first n verses
Get the number of verses from the user Initialize bottles to 99. Loop while the verses are greater than 0. If there is 1 bottle of beer left Output the modified last verse. else Output the first half of the verse. Subtract 1 from the bottles remaining. Output the second half of the verse. End if Subtract 1 from the number of verses remaining