TAILIEUCHUNG - Lecture Elementary programming with C - Session 3: Operators and expressions

After completing this unit, you should be able to: Explain assignment operator, understand arithmetic expressions, explain relational and logical operators, understand bitwise logical operators and expressions, explain casts, understand precedence of operators. | Operators and Expressions Session 3 Operators and Expression Objectives Explain Assignment Operator Understand Arithmetic Expressions Explain Relational and Logical Operators Understand Bitwise logical operators and expressions Explain casts Understand Precedence of Operators Elementary Programming with C/Session 3/ of 25 Expressions Combination of Operators and Operands Example 2 * y + 5 Operands Operators Elementary Programming with C/Session 3/ of 25 The Assignment Operator variable_name = expression; lvalue rvalue Assignment operator The assignment operator(=) can be used with any valid C expression (Left value) (Right value) Elementary Programming with C/Session 3/ of 25 Multiple Assignment Many variables can be assigned the same value in a single statement a = b = c = 10; However, you cannot do this : int a = int b = int b = int c = 10 X Elementary Programming with C/Session 3/ of 25 Operators 4 Types Arithmetic Relational Logical Bitwise Elementary Programming with C/Session 3/ of 25 Arithmetic Expressions Mathematical expressions can be expressed in C using arithmetic operators Examples a * (b + c/d)22 ++i % 7 5 + (c = 3 + 8) Elementary Programming with C/Session 3/ of 25 Relational & Logical Operators-1 Test the relationship between two variables, or between a variable and a constant Used to Relational Operators Elementary Programming with C/Session 3/ of 25 Logical operators are symbols that are used to combine or negate expressions containing relational operators Relational & Logical Operators-2 Expressions that use logical operators return zero for false, and 1 for true Example: if (a>10) && (a Elementary Programming with C/Session 3/ of 25 Bitwise Logical Operators-1 Processes data after converting number to its binary equivalent. (Bit wise representation) AND ( NUM1 & NUM2) Return 1 if both the operands are 1 OR ( NUM1

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.