// Purpose: A program to demonstrate constants // Author: Keith Shomper // Date: 9/12/03 #include using namespace std; int main () { // initialize variables with different literal values int x = 0; int y = 017; int z = 0xF; // note that these are constants--so they are CAPITALIZED const float X = 23.4; const double Y = 15E+2; // a character literal uses single quotes char a = 't'; // a string literal uses double quotes string s = "This is a string."; // print out the variables cout << "x = " << x << endl; cout << "y = " << y << endl; cout << "z = " << z << endl; cout << "X = " << X << endl; cout << "Y = " << Y << endl; cout << "a = " << a << endl; cout << "s = " << s << endl; // change the value of x and print it again x = y + z; cout << "x = " << x << endl; // what happens when we mix types? x = X; cout << "x = " << x << endl; return 0; }