Homework 09: Nested loops
Name: _____________________________________________ Alpha: ___________________
Describe help received: ________________________________________________________
- Due before class on Wednesday, February 1
- This homework contains code to be submitted electronically.
Put your code in a folder called
hw09and submit using the204subcommand. - This is an electronic homework and you do not need to print out anything to turn in during class.
Assignment
- Required reading: Section 5 (Nested loops & Stepwise refinement) from the Unit 3 notes, Note: You do not need to go through the full example in section 5.4 (stepwise refinement from the inside out) if you will be in class.
-
Write a program called
counting.cthat reads an integer \(n\) from the user, and then uses a nested loop to count from 1 up to 1, then from 1 up to 2, then from 1 up to 3, etc., and finally from 1 up to \(n\).Example of running your program:
roche@ubuntu$./countingEnter n:511 21 2 31 2 3 41 2 3 4 5Note: be careful not to print an extra space at the end of each line!