CGS 3408- Recitation 1

Summary: During this lab we are going to show how to:

Note: This is the best time to ask questions about getting started. Please take notes on the topics so you can do this independtly from home.

Getting Microsoft Visual C++ Express


Do this from home. We should already have the software in this lab.
  1. Download the software from the site here.
  2. Save the file to the Desktop.
  3. Follow installation directions.

Using Microsoft Visual C++ Express


  1. Click Start->All Programs->Microsoft C++ Express-> ....
  2. Click close if a Tip of the Day shows up
  3. File -> New..
  4. Select the File tab, and choose C++ source file
  5. Type a file name in the text box (filename = username_Lab1)

    Now a new file pops up and is ready for code. If you are having problems here please raise your hand for assistance.

  6. Copy and Paste the Example code 1 at the bottom of this page into the editor window (your new file).
  7. Click Build->Build or hit F7
  8. Click Build->Execute filename.exe or hit CTRL+F5

    You have just completed your first C++ program.
    NOTE: Make sure you get checked off before leaving class for completing this section of the recitation.

Code example overview



Example 1 Code


//Program Header #include <iostream>

using namespace std;
int main()
{
double hours ,rate,pay;

//get # of hours worked
cout << "How many hours did you work?" << endl;
cin >> hours;

// get the hourly pay rate
cout<<"How much do you get payed an hour?"< cin>>rate;

//Calculate the pay
pay=hours*rate;

//Display the final pay
cout<<"You have earned $"<< pay <
return 0;
}


Additional Examples