CGS 3408- Recitation 1
Summary: During this lab we are going to show how to:
- Start Microsoft Visual C++ Express
- Create a new C++ project
- Review the features of Microsoft Visual C++
- Compile and Execute our first C++ programs
- Review topics of programming from lecture (Input/Ouput and variables)
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.
- Download the software from the site here.
- Save the file to the Desktop.
- Follow installation directions.
Using Microsoft Visual C++ Express
- Click Start->All Programs->Microsoft C++ Express-> ....
- Click close if a Tip of the Day shows up
- File -> New..
- Select the File tab, and choose C++ source file
- 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.
- Copy and Paste the Example code 1 at the bottom of this page into the editor window (your new file).
- Click Build->Build or hit F7
- 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
- Basic Structure
- Input/Output (cout & cin)
- Variables
- Types
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