C for Dummies 2nd edition phần 5

Các từ khóa nếu cho phép bạn đặt các loại quyết định thành gram ủng hộ của bạn. Các quyết định được dựa trên một sự so sánh. Ví dụ: Nếu nội dung của biến X lớn hơn Y biến, la hét như Nếu nội dung của các calo biến rất cao, có hương vị rất tốt. | 148 Part III Giving Your Programs the Ability to Run Amok The if keyword allows you to put these types of decisions into your programs. The decisions are based on a comparison. For example 1 If the contents of variable X are greater than variable Y scream like they re twisting your nose. If the contents of the variable calories are very high it must taste very good. If it ain t broke don t fix it. If Doug doesn t ask me out to the prom I ll have to go with Charley. All these examples show important decisions similar to those you can make in your C programs by using the if keyword. However in the C programming language the if keyword s comparisons are kind of sort of dare I say it mathematical in nature. Here are more accurate examples If the value of variable A is equal to the value of variable B If the contents of variable ch are less than 132 If the value of variable zed is greater than 1 000 000 These examples are really simple scales-of-justice evaluations of variables and values. The if keyword makes the comparison and if the comparison is true your program does a particular set of tasks. 1 if is a keyword in the C programming language. It allows your programs to make decisions. 1 if decides what to do based on a comparison of usually two items. The comparison that if makes is mathematical in nature Are two items equal to greater than less than and so on to each other If they are a certain part of your program runs. If not that part of the program doesn t run. The if keyword creates what is known as a selection statement in the C language. I wrote this topic down in my notes probably because it s in some other C reference I have read at some time or another. Selection statement. Impress your friends with that term if you can remember it. Just throw your nose in the air if they ask what it means. That s what I do. The computer-genie program example The following program is one of many silly computer guess-the-number programs you write when you find out

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.