Chapter 1 C++ Basics

Chapter Objectives.♦ Introduction to C++.♦ Origins, Object-Oriented Programming, Terms♦ Variables, Expressions, andAssignment Statements.♦ Console Input/Output ♦ Program Style ♦ Libraries and | Chapter 1 C++ Basics Learning Objectives Introduction to C++ Origins, Object-Oriented Programming, Terms Variables, Expressions, and Assignment Statements Console Input/Output Program Style Libraries and Namespaces Introduction to C++ C++ Origins Low-level languages Machine, assembly High-level languages C, C++, ADA, COBOL, FORTRAN Object-Oriented-Programming in C++ C++ Terminology Programs and functions Basic Input/Output (I/O) with cin and cout Display A Sample C++ Program (1 of 2) Display A Sample C++ Program (2 of 2) C++ Variables C++ Identifiers Keywords/reserved words vs. Identifiers Case-sensitivity and validity of identifiers Meaningful names! Variables A memory location to store data for a program Must declare all data before use in program Data Types: Display Simple Types (1 of 2) Data Types: Display Simple Types (2 of 2) Assigning Data Initializing data in declaration statement Results "undefined" if you don’t! int myValue = 0; Assigning data during . | Chapter 1 C++ Basics Learning Objectives Introduction to C++ Origins, Object-Oriented Programming, Terms Variables, Expressions, and Assignment Statements Console Input/Output Program Style Libraries and Namespaces Introduction to C++ C++ Origins Low-level languages Machine, assembly High-level languages C, C++, ADA, COBOL, FORTRAN Object-Oriented-Programming in C++ C++ Terminology Programs and functions Basic Input/Output (I/O) with cin and cout Display A Sample C++ Program (1 of 2) Display A Sample C++ Program (2 of 2) C++ Variables C++ Identifiers Keywords/reserved words vs. Identifiers Case-sensitivity and validity of identifiers Meaningful names! Variables A memory location to store data for a program Must declare all data before use in program Data Types: Display Simple Types (1 of 2) Data Types: Display Simple Types (2 of 2) Assigning Data Initializing data in declaration statement Results "undefined" if you don’t! int myValue = 0; Assigning data during execution Lvalues (left-side) & Rvalues (right-side) Lvalues must be variables Rvalues can be any expression Example: distance = rate * time; Lvalue: "distance" Rvalue: "rate * time" Assigning Data: Shorthand Notations Display, page 14 Data Assignment Rules Compatibility of Data Assignments Type mismatches General Rule: Cannot place value of one type into variable of another type intVar = ; // 2 is assigned to intVar! Only integer part "fits", so that’s all that goes Called "implicit" or "automatic type conversion" Literals 2, , "Z", "Hello World" Considered "constants": can’t change in program Literal Data Literals Examples: 2 // Literal constant int // Literal constant double "Z" // Literal constant char "Hello World" // Literal constant string Cannot change values during execution Called "literals" because you "literally typed" them in your program! Escape Sequences "Extend" character set Backslash, \ preceding a character Instructs compiler: a special "escape character" .

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
179    64    1    19-04-2024
214    124    1    19-04-2024
131    54    3    19-04-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.