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

    You may work with a partner for this lab. Working with a teammate offers several advanages:

    • Two people do not think alike. By collaborating with another student you can gain insights into programming concepts that might otherwise escape you.
    • You have a built-in support system: You may have an immediate answer to a simple question that your teammate has, or vice-versa. Sometimes individual students are hesitant to ask a teacher a question because they mistakingly believe that everyone else knows the answer and the teacher will think they are stupid. Having a teammate in the same situation can make it less threatening to ask for help.
    • Working with a classmate is more fun.

    You may elect to work alone, if you prefer.

    Regardless of whether you work alone or with a partner, on this and all future labs you are responsible for understanding all aspects of the work required to complete the assignment.

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

  6. Using the Visual Studio 2013 integrated development environment

    Watch the video at http://computing.southern.edu/halterman/Videos/Cpp/firstprogram-vs-cpp-2012/firstprogram-vs-cpp-2012.html. The video shows how to use Visual Studio 2012 to develop and run C++ programs. Microsoft has now released Visual Studio 2013 Preview, but the process for creating a C++ project is essentially the same. Appendix A in your textbook provides a written description of the process of creating a new C++ project in Visual Studio 2013.

    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.

  7. 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 http://computing.southern.edu/halterman/repository/ClassCode/124/.

    Save the most recent zip file to your USB drive. Right click on the downloaded file and extract (unzip) its contents. Once you have downloaded and unzipped the file, you can launch Visual Studio by double clicking the .sln file in the CPTR124 folder. (Note: Windows explorer will let you open the zip file and browse its contents, but Visual Studio cannot open the .sln file while it is still in the zipped archive.) Visual Studio will open up with all the projects we worked on in class. To work with a particular project, right click on the project in the Solution Explorer pane and select "Set as StartUp Project." After doing so, you can build and run the program in the normal way.

    Note: We will be using Visual Studio 2013 this semester. Visual Studio 2012 cannot properly process a .sln created by VS 2013. You should use VS 2013 to build and run the class code found in the course archive. If you are using a toolset different from VS 2013, you can extract the CPTR124.zip file, search for the .cpp files in subfolders, and manually copy them into your build environment.

    Be sure you are able to build and run all the programs we have written in class.

    The code repository site is updated after each class, so you should re-download this file frequently.

    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.

  8. Creating a simple C++ program

    Open Visual Studio 2013, 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:

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

      cout << "RRRRRRRRRRR        LLLL             HHHH     HHHH" << endl;
      

      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.

  10. 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 (not the CPTR-124L-A lab link). If you worked with a partner, your partner should submit his/her own copy of the code to eclass.

  11. Finish up

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

  12. Log out

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