COMP 104 : Programming

Lab 1 : PC and C++ Basics


If you have trouble with any of the below steps, please raise your hand during the lab and the TA will help.

1.    Use Netscape Communicator or Internet Explorer to access the comp104 webpage. Open the lecture notes for the first class, and print them out. Print four slides per physical page to save paper and save print quota. To do this, after selecting "Print" from the "File" menu, hit the "Properties" button, then from the "Layout" tab hit the "Advanced..." button, set "Pages per sheet" to "4 (Landscape)", and hit "OK".

2.    Access the comp104 newsgroup hkust.cs.class.104 through the comp104 webpage to see the latest postings.

3.    Send an email to your TA that includes your name, email address, and lab section.

4.    Follow the below "Basic Instructions in Writing Visual C++ Programs" to start and run VC++ on the following short program:

        #include <iostream>
        using namespace std;
        int main(){
            cout << "Hello world!" << endl;
            cout << "Comp104 is great" <<endl;
            return 0;
        }

You can copy and paste the above program into a source file "lab1.cpp" in VC++.

5.    Change the output string "hello world!" to your own message (e.g., "Hi Mom!" or "I am hungry!").

6. Also, delete the semicolon after the "endl" to see what error message appears when you compile the program. Also, how is the output different without "endl"?

        cout << "hello world!";

7.    Demo your working program for step 5 for your TA. If for some reason you cannot finish before the end of the lab period, email your program to your TA by Sunday 11 September 5PM (please include your name and lab section in the subject line of the email).

8.    Close all your applications and Log Off.
 


Basic Instructions in Writing Visual C++ Programs

Start up Visual C++

Create a new C++ file A new blank file "lab1.cpp" will be created, and a new window for that file will be displayed. Copy and paste the "Hello World" program into the file. Now save your program: Compile, link, and run your program

Now you are ready to compile your program. If there are any syntax errors, error messages will be displayed in a window at the bottom of the screen. You should correct all the errors.

A DOS prompt window will be displayed, and your program will start running. Hit any key and the DOS window will disappear.

Save your file to floppy disk

 Use Windows Explorer to delete C:\Documents and Settings\login\lab1.cpp, and empty the recycle bin. Otherwise your work may be lost or stolen by others.