// This is the sample source code I wronte in class on 10/2, cleaned up a bit. #include #include using namespace std; int main() { // these are primitive data type DECLARATIONS int i; // this is an integer variable int another; // another integer variable int g, z, y, x; // declare multiple variables together int a=0, b, other=3; // you can mix and match declarations/initializations togther float f; // this is a float variable double d; // this is a double variable char c; // this is a char variable // Variable initializations i = 5; cout << "The BEFORE i value is:" << " " << i << endl; cout << endl; // here is just a line return on its own. i = another; cout << "Change to: " << i << endl; // prints the value of i i = i + 1; cout << "(i+1)= " << i << endl; // prints updated i value i = i * 5 + 1 - 3; cout << "(i*5+1-3)= " << i << endl; // prints updated i value i = 12.4; // converted to 12 by compiler f = 25.4999999; // no precision with this one. d = 23.34; // doubles are used for dollar values since they are more precise then a float // print out i, f, d values in one line cout << " i = " << i << " f = " << f << " d = " << d << endl; // "String" is arelly an object type string n; double tank = 10; double freeway = 23.5; double highway = 28.6; // ask user for their name cout << "Enter your name: "; cin >> n; // prints out name + "Hello" cout << endl << "Hello " << n << endl; // you can declare a name on its own as well string myinfo = "My Info"; cout << myinfo; cout << endl << "Enter an integer value: "; cin >> i; cout << endl << "The value you entered is: " << i << endl; return 0; }