// pgm1 -- data, variables, expressions // 8/31/16 #include #include using namespace std; int main() { int area, length, width; length = 12; width = 15; area = length * width; // times cout << "The length is: " << length << " the width is: " << width << " and the area is " << area << "." << endl; // mixing data types int x=1.9; cout << "x is " << x << endl; // using parenthesis to override operator precedence int a=10, b=20; double avg = (10 + 20) / 2; cout << "avg is: " << avg << endl; // integer division cout << "7/2 with integer division " << 7/2 << endl; double answer; answer = 7/2; cout << "even in a double variable " << answer << endl; answer = 7/2.0; cout << "now answer is " << answer << endl; // modulus operator % (same precedence as * and /) int hour = 2; cout << "It is now 2:00. After waiting 13 hours, the time is: " << (2+13) % 12 << endl; // string variable string name; name = "Alice"; cout << "Hello " << name << endl; return 0; }