Declaring bool Variables

Kê khai các biến bool Trong thế giới lập trình (không giống như trong thế giới thực), tất cả mọi thứ là màu đen hoặc trắng, đúng hay sai, đúng hoặc sai. Ví dụ, nếu bạn tạo một biến số nguyên được gọi là x, chuyển nhượng giá trị 99 cho x, và sau đó yêu cầu, | Declaring bool Variables In the world of programming unlike in the real world everything is black or white right or wrong true or false. For example if you create an integer variable called x assign the value 99 to x and then ask Does x contain the value 99 the answer is definitely true. If you ask Is x less than 10 the answer is definitely false. These are examples of Boolean expressions. A Boolean expression always evaluates to true or false. NOTE The answers to these questions are not definitive for all programming languages. An unassigned variable has an undefined value and you cannot for example say that it is definitely less than 10. Issues such as this one are a common source of errors in C and C programs. The Microsoft Visual C compiler solves this problem by ensuring that you always assign a value to a variable before examining it. If you try to examine the contents of an unassigned variable your program will not compile. Microsoft Visual C provides a data type called bool. A bool variable can hold one of two values true or false. For example the following three statements declare a bool variable called areYouReady assign true to the variable and then write its value to the console bool areYouReady areYouReady true areYouReady writes .

Bấm vào đây để xem trước nội dung
TÀI LIỆU MỚI ĐĂNG
19    92    2    26-06-2024
34    71    1    26-06-2024
Đã 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.