Programming in C++ Header files limits and float s contain constants whose values are the maximum and minimum for your machine such constants are FLT MAX, FLT MIN LONG MAX LONG MIN include limits using namespace std cout≤<“ Maximum long is“<< LONG MAX≤<end; cout<<“ Minimum long is“<< LONG MIN<<endl 16
16 Header Files climits and cfloat ❖ contain constants whose values are the maximum and minimum for your machine ❖ such constants are FLT_MAX, FLT_MIN, LONG_MAX, LONG_MIN #include < climits > using namespace std ; . . . cout << “Maximum long is “ << LONG_MAX << endl ; cout << “Minimum long is “ << LONG_MIN << endl ;
Programming in C++ Assignment Expressions Assignment expression A C++ expression with (1) a value and (2) the side effect of storing the expression value into a memory location Example: delta =2*12 Expression statement: a statement formed b appending a semicolon to an expression Example: delta =2 12
17 Assignment Expressions ❖Assignment expression: A C++ expression with (1) a value and (2) the side effect of storing the expression value into a memory location. Example: delta = 2*12 ❖Expression statement: a statement formed b appending a semicolon to an expression. Example: delta = 2*12 ;
Programming in C++ C++ Has Combined Assignment Operators int age cIn > age 3 Write a statement to add 3 to age. age age+3: OR, age +=3; 18
18 C++ Has Combined Assignment Operators int age ; cin >> age ; Write a statement to add 3 to age. age = age + 3 ; OR, age += 3 ;
Programming in C++ Write a statement to subtract 10 from weight int weight cin > weight weight weight-10 OR weight -= 10; 19
19 Write a statement to subtract 10 from weight int weight ; cin >> weight ; weight = weight - 10 ; OR, weight -= 10 ;
Programming in C++ Write a statement to divide money by 5.0 float money i cIn > money money money /5.0 OR money E 5.0 20
20 Write a statement to divide money by 5.0 float money ; cin >> money ; money = money / 5.0 ; OR, money /= 5.0 ;