CPTR 124 Fundamentals of Programming


The purpose of this lab is to acquaint you with the environment in which we will be developing C++ programs.


  1. Log into a lab machine

    If you are not using your own laptop, log into a lab workstation using your SAU username and password.

  2. Accessing information on the web

    Point your browser to the the CPTR 124 web page:

    • Go to http://computing.southern.edu/halterman,
    • click the CPTR 124 link,
    • click the Labs link, and
    • look at Lab 1.

  3. Becoming acquainted with the lab

    Quickly read over this entire lab before you begin to work on the computer. This will give you a good overview of what we will be doing today. For future labs you should make a habit of reading the entire lab before you begin any work. Ideally you will have read the assignment over completely (and maybe even begun work on it) before you come to lab.

  4. Preparing your working folder

    (If you are working on your own computer, you may skip this section.)

    Insert your USB pen drive into the USB port of the computer. Within Windows, open an Explorer window and navigate to your USB drive. Create a folder named cptr124 on your USB drive. All your programming work for labs in this class should be stored in that folder.

  5. Using the Visual Studio integrated development environment

    Read Appendix A in your textbook. It outlines the steps for creating a C++ project under Visual Studio.

    Follow the steps indicated, but where the instructions mention setting the location of your project folder, you should use the cptr124 folder on your USB drive. The instructions show you how to create a particular program; modify the program so that it prints

    Hey! This is part 1 of Lab 1.

    Build and run you program and demonstrate that it works correctly. Before beginning the second part of this lab quit Visual Studio.

  6. Getting and working with the code we develop in class

    To start this part of the lab you should not have Visual Studio open.

    We will work on many programs in class, and all the code we develop in class is available online at the link provided below. It is very useful to get the code we do in class and play with it (modify it, break it, etc.) until you better understand how it works. If you do not bring a laptop to class, this beats copying it down on paper in class and then typing it into Visual Studio later. Even if you do bring a laptop and type in the code as we go, the code repository can be useful to help you find typographical errors in your code.

    Direct your browser to https://github.com/halterman/124_F17/.

    Navigate to and download one of the .cpp files. Create a new project in Visual Studio and add an empty C++ file to the project. Copy the contents of the file you downloaded into the Visual Studio editor.

    Be sure you are able to build and run the program you downloaded.

    The code repository site is updated after each class, so after each class you can (and should) download the files we develop in class and experiment with them.

    It is important that you are able to download files and work with them, not only so you can experiment with class code, but also because future labs may require you to incorporate into your projects C++ source files that I provide. Sometimes it is handy to copy parts of programs we write in class and paste them into your own projects.

    When you have finished this section close Visual Studio.

  7. Creating a simple C++ program

    Open Visual Studio, create a new project, and write a C++ program that displays the initials of your name on the screen. These initials will be large letters that you must construct. Each letter is created by composing many smaller “normal” characters into the shape of the desired letter:

  8. RRRRRRRRRRR        LLLL             HHHH     HHHH
     RR        RR       LL               HH       HH
     RR        RR       LL               HH       HH
     RR        RR       LL               HH       HH
     RR        RR       LL               HH       HH
     RRRRRRRRRR         LL               HHHHHHHHHHH
     RR    RR           LL               HH       HH
     RR     RR          LL               HH       HH
     RR      RR         LL        LL     HH       HH
    RRRR      RRR      LLLLLLLLLLLLL    HHHH     HHHH
    

    If you are working with a partner, each person should write a program to do his/her own initials.

    You should not devise a sophisticated algorithm to complete this part; instead, simply use a series of printing statements that each print a horizontal slice of all three letters.
    In order to do this part of the assignment:

    1. Create a new project. Initials is a good name for the project.
    2. Create a program similar to any we have seen before.
    3. Duplicate the printing line about 10 times. You can duplicate the line by the normal Windows means of copying and pasting. (Highlight the line with the mouse, select Edit→Copy, move the cursor to the next line, and select Edit→Paste.)

    4. Change the contents of the quotation to form slices of the initials of your name. For example, for my initials above, the first statement would look like:

      std::cout << "RRRRRRRRRRR LLLL HHHH HHHH" << '\n';

      This printing statement makes the top row of letters (the first "slice") in my initials.

    5. Compile and run the program to make sure it works. If necessary, modify your program until you are satisfied that it works correctly.

    Hint: Watch out for mixing tabs and spaces within the editor. Tabs may be treated differently within the editor than in the window that displays the program's output. It is best to use only spaces when laying out your initials within the editor.

  9. Check out

    I will review your lab with you before you leave. After your lab has been reviewed, please submit your initials C++ source code (the .cpp file) to eclass.e.southern.edu/. Log into eclass, select the CPTR-124-A link.

  10. Finish up

    You should always close Visual Studio when you are finished working with it. Select File → Exit.

  11. Log out

    Don't forget to safely remove your USB drive and log out of your lab workstation before you leave.