Your browser is unsupported

We recommend using the latest version of IE11, Edge, Chrome, Firefox or Safari.

Lab 1

June 17, 2020
Instructions:
This first lab will get you started on code similar to what you need for the first programming assignment.  Log in to your Zybooks 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 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.


  What you will Need to Do:
This Lab activity will help you prepare for program 1.  Hint: Consider that we could use the following 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:
   int i=1;
   while( i<=5) {
      cout << i << " ";
      i  ;
   }
(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:----
(2) 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:   *

(3 Extra Credit) Given input of a number, display an ASCII character box of that size, filled with '.' character.
Hint: Use the setfill() command to set the character used to fill in the output field. Alternatively you could again use a loop.
Enter a number: 3
Result is: 
 ------
|......|
|......|
|......|
 ------