Lab 1: Format Output

Welcome to the first CS 141 Lab!

Getting Started:

  1. Please find a lab partner to work with during lab. (This is a requirement)

    • Introduce yourself, and get your partners name because you will need it for the quiz. It must be spelled correctly!

    • We will switch partners every couple of weeks

  2. This first lab will help you get started on code similar to what you need for the first programming assignment

  3. Each lab will begin with a quiz within the first few minutes of lab

  4. You may use your own machine or if you are utilizing the lab computers your Username and Password is shown below:

    • Username: Your NetID

    • Password: Your UIC Password

Quiz

As stated we will start each lab with a brief quiz which you will do individually. The quiz will be done during the first few minutes of every lab. Your lab TA will tell you the password you will need to get into the quiz for your section. Please click on your lab section to access your quiz:

9am, 10am, 11am, 12pm, 1pm, 2pm, 3pm, 4pm, 5pm

After you have finished your quiz, if you have not already done so review the course syllabus Academic Honesty policy. You must then enter your information and acknowledge that you have read it and agree to abide by it using this google form.

Instructions

Hint:

Consider that we could use the statement: cout << "some text" << endl; to print out the text: some text and we could use the following variable declaration and while loop to give the output 1 2 3 4 5

You and your partner must choose one computer that you will use for your lab activity. For the other one log out and put it away if it is a laptop. You will take turns typing (the "driver") and watching/suggesting (the "navigator"). You will switch roles every 10 minutes, prompted by your TA (or set your own timer). This is called "pair programming" and is considered a standard industry best-practice for getting optimal results.

Log in to your Zyooks account. If you haven't already signed up in Zybooks, see the course syllabus on how to do this. Open the first lab, found in Zybooks section 1.23. Edit and run your program in "Develop Mode", and then switch to "Submit Mode" when you want to run the official tests. (Pictures shown at the bottom of the webpage)


You need to write the code to do the following.

  1. Given input of a number, display a line of dashes of that length, separated by spaces. (1 point) Hint: I suggest you use a while loop or a for loop.

Enter a number: 4

Result is:----

  1. Given input of a number, display that number of spaces followed by an asterisk. (1 point) Hint: Use the setw() command to set the field width. Alternatively you could again use a loop.

Enter a number: 3

Result is: *

  1. (Extra Credit) Given input of a number, display an ASCII character box of that size, filled with the '.' character. (1 point)

Hint: Use the setfill() command to set the character used to fill in the output field. Alternatively you could again use a loop.

Develop Mode:

Submit Mode: