Lecture C++ programming: from problem analysis to program design - Chapter 4: Control structures I (Selection)

After completing this unit, you should be able to: Learn about control structures; examine relational and logical operators; explore how to form and evaluate logical (boolean) expressions; discover how to use the selection control structures if, , and switch in a program; learn to use the assert function to terminate a program;. | C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 4: Control Structures I (Selection) C++ Programming: From Problem Analysis to Program Design, Fourth Edition Objectives In this chapter, you will: Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean) expressions Discover how to use the selection control structures if, , and switch in a program Learn to use the assert function to terminate a program C++ Programming: From Problem Analysis to Program Design, Fourth Edition Control Structures A computer can proceed: In sequence Selectively (branch) - making a choice Repetitively (iteratively) - looping Some statements are executed only if certain conditions are met A condition is met if it evaluates to true C++ Programming: From Problem Analysis to Program Design, Fourth Edition Control Structures (continued) C++ Programming: From Problem Analysis to Program Design, . | C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 4: Control Structures I (Selection) C++ Programming: From Problem Analysis to Program Design, Fourth Edition Objectives In this chapter, you will: Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean) expressions Discover how to use the selection control structures if, , and switch in a program Learn to use the assert function to terminate a program C++ Programming: From Problem Analysis to Program Design, Fourth Edition Control Structures A computer can proceed: In sequence Selectively (branch) - making a choice Repetitively (iteratively) - looping Some statements are executed only if certain conditions are met A condition is met if it evaluates to true C++ Programming: From Problem Analysis to Program Design, Fourth Edition Control Structures (continued) C++ Programming: From Problem Analysis to Program Design, Fourth Edition Relational Operators A condition is represented by a logical (Boolean) expression that can be true or false Relational operators: Allow comparisons Require two operands (binary) Evaluate to true or false C++ Programming: From Problem Analysis to Program Design, Fourth Edition Relational Operators (continued) C++ Programming: From Problem Analysis to Program Design, Fourth Edition Relational Operators and Simple Data Types You can use the relational operators with all three simple data types: 8 evaluates to false Comparing Characters C++ Programming: From Problem Analysis to Program Design, Fourth Edition Relational Operators and the string Type Relational operators can be applied to strings Strings are compared character by character, starting with the first character Comparison continues until

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.