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. 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.

  2. 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.

  3. Installing the necessary software

    Before you can write a C++ program you must install the appropriate software development tools. The actual tools will vary slightly depending on whether you are using a Windows PC or a Mac. Follow the instructions found here to install the required software development tools.

  4. Writing a simple C++ program

    Copy a working VSCode project folder to a new folder. Modify the program (the .cpp file) in the copied folder so that it prints the following:

    Hey! This is part 1 of Lab 1.

    Build and run your program and demonstrate that it works correctly. Before beginning the second part of this lab quit VSCode.

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

    To start this part of the lab you should not have VSCode 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_W18/.

    Navigate to and download one of the .cpp files. Copy the complete VSCode project folder from the previous exercise, and replace the .cpp with the file you just downloaded. Open this new project with VSCode. Modify the first line of the file named Makefile so that it will use the new .cpp source file you downloaded.

    (Rather than downloading the file from the repository site, you can just copy and paste the code from your browser into the VSCode editor window.)

    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 you can close VSCode.

  6. Creating a simple C++ program

    Copy one of your existing VSCode project folders. Modify the C++ source file so that the program 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:

  7. 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
    

    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 program similar to any we have seen before that print text in the console window.
    2. Duplicate the printing line about 10 times. You can duplicate the line by the normal means of copying and pasting.
    3. 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.

    4. 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.

  8. Check out

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

  9. Finish up

    You should always close VSCode when you are finished working with it.