CIS-155

hw 1: not to be turned in


Description

The purpose of this assignment is to review the basics of Command Window and help you figure out your way to create your first Microsoft VC++ project. In this exercise, you will compile, execute, and modify your first C++ program.

Instructions

  1. Explain the purpose of the following commands:
    • dir
    • mkdir
    • cd
    • echo
    Hint: use help command to print short descriptions of these commands and their arguments.

  2. Using instructions from the lecture handout, write, compile, and execute a C++ program that prints a welcoming message of your choice.

  3. Using instructions from the lecture handout, create an empty Win32 Console application VC++ project. Add C++ file containing your program to the project. Compile it using VC++ "Build" menu. Execute your program from the command window.

  4. Modify your program using VC++ code editor as follows:
    • Add two global integer variables to your program and initialize their values:
              int one = 2;
              int two = 1;
                                      
    • In your main function, print the values of both variables on the screen.
    • In your main function, swap the values of variables:
              int tmp;
              tmp = one;
              one = two;
              two = tmp;
                                      
    • Print the values of both variables on the screen again after the swap.


  5. Why a temporary variable was necessary to do the swap?

  6. In VC++ program editor, place your text cursor on the line tmp = one; and press the F9 key to set a debugging breakpoint. Run your program in debug mode using VC++ menu Debug -> Start or simply by pressing F5. Step through the lines of your program in debugger. Switch between debug windows: Autos, Locals, Registers, and Call stack. You should be able to see your variables and their values in those windows. Hit F5 (continue) to finish the debugging session.

  7. Add some comments to your program.