cout endl 3t a a tb b tc c td d endl endl a 5 cannot use a 5f b 10 c 20 d 30

# Cout endl 3t a a tb b tc c td d endl endl a 5 cannot

This preview shows page 5 - 11 out of 26 pages.

cout << endl << "3.\t" << "a = " << a << "\tb = " << b << "\tc = " << c << "\td = " << d << endl << endl; a = 5; //cannot use a = 5f; b = 10; c = 20; d = 30; cout << endl << "4.\t" << "a = " << a << "\tb = " << b << "\tc = " << c << "\td = " << d << endl << endl; a = 5.f; 5
Lesson 4 - Sample Programs b = 10.f; c = 20.f; d = 30.f; cout << endl << "5.\t" << "a = " << a << "\tb = " << b << "\tc = " << c << "\td = " << d << endl << endl; a = 5.0f; b = 10.0f; c = 20.0f; d = 30.0f; cout << endl << "6.\t" << "a = " << a << "\tb = " << b << "\tc = " << c << "\td = " << d << endl << endl; return 0; } /* No manipulators are on (or set) 6
Lesson 4 - Sample Programs 7
Lesson 4 - Sample Programs 8
Lesson 4 - Sample Programs //SP4_2.cpp // Logical and relational operators are demonstrated. #include <iostream> #include <iomanip> using namespace std; int main() { bool found = true ; //!found = false int age = 20; double hours = 45.30; double overTime = 15.00; int count = 20; char ch = 'B' ; cout << fixed << showpoint << setprecision(2); //note how all three manipulators are set cout << "found = " << found << ", age = " << age << ", hours = " << hours << ", overTime = " << overTime << "," << endl << "count = " << count << ", ch = " << ch << endl << endl; cout << "!found evaluates to " << !found << endl; cout << "hours > 40.00 evaluates to " << (hours > 40.00) << endl; cout << "!age evaluates to " << !age << endl; cout << "(!found && (age >= 18)) evaluates to " << (!found && (age >= 18)) << endl; cout << "!(found && (age >= 18)) evaluates to " << (!(found && (age >= 18))) << endl; cout << "hours + overTime <= 75.00 evaluates to " << (hours + overTime <= 75.00) << endl; cout << "(count >= 0) && (count <= 100) evaluates to " << ((count >= 0) && (count <= 100)) << endl; cout << "('A' <= ch && ch <= 'Z') evaluates to " << ( 'A' <= ch && ch <= 'Z' ) << endl; cout << endl << "logical operator changed to logical or ||" << endl << endl; cout << "(!found || (age >= 18)) evaluates to " << (!found || (age >= 18)) << endl; cout << "!(found || (age >= 18)) evaluates to " << (!(found || (age >= 18))) << endl; cout << "hours + overTime <= 75.00 evaluates to " << (hours + overTime <= 75.00) << endl; cout << "(count >= 0) || (count <= 100) evaluates to " << ((count >= 0) || (count <= 100)) << endl; cout << "('A' <= ch || ch <= 'Z') evaluates to " << ( 'A' <= ch || ch <= 'Z' ) << endl; return 0; } /* found = 1, age = 20, hours = 45.30, overTime = 15.00, count = 20, ch = B !found evaluates to 0 hours > 40.00 evaluates to 1 !age evaluates to 0 9
Lesson 4 - Sample Programs (!found && (age >= 18)) evaluates to 0 !(found && (age >= 18)) evaluates to 0 hours + overTime <= 75.00 evaluates to 1 (count >= 0) && (count <= 100) evaluates to 1 ('A' <= ch && ch <= 'Z') evaluates to 1 logical operator changed to logical or || (!found || (age >= 18)) evaluates to 1 !(found || (age >= 18)) evaluates to 0 hours + overTime <= 75.00 evaluates to 1 (count >= 0) || (count <= 100) evaluates to 1 ('A' <= ch || ch <= 'Z') evaluates to 1 */

#### You've reached the end of your free preview.

Want to read all 26 pages?

• Fall '15
• Marinolent