TAILIEUCHUNG - A Complete Guide to Programming in C++ part 12

A Complete Guide to Programming in C++ part 12. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | RELATIONAL OPERATORS NOTE The Result of Comparisons Each comparison in C is a bool type expression with a value of true or false where true means that the comparison is correct and false means that the comparison is incorrect. Example length circuit false or true If the variables length and circuit contain the same number the comparison is true and the value of the relational expression is true. But if the expressions contain different values the value of the expression will be false. When individual characters are compared the character codes are compared. The result therefore depends on the character set you are using. The following expression results in the value true when ASCII code is used. Example A a true since 65 97 Precedence of Relational Operators Relational operators have lower precedence than arithmetic operators but higher precedence than assignment operators. Example bool flag index max - 1 In our example max - 1 is evaluated first then the result is compared to index and the value of the relational expression false or true is assigned to the flag variable. Similarly in the following Example int result result length 1 limit length 1 is evaluated first then the result is compared to limit and the value of the relational expression is assigned to the result variable. Since result is an int type a numerical value is assigned instead of false or true . 0 for false and 1 for true. It is quite common to assign a value before performing a comparison and parentheses must be used in this case. Example result length 1 limit Our example stores the result of length 1 in the variable result and then compares this expression with limit. You cannot use the assignment operator to compare two expressions. The compiler will not generate an error message if the value on the left is a variable. This mistake has caused headaches for lots of beginners when troubleshooting their programs. 90 CHAPTER 5 OPERATORS FOR FUNDAMENTAL TYPES LOGICAL OPERATORS Truth table for .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.