180 likes | 275 Views
Chapter 2. Introduction to The C++ Language. Figure 2-1. Figure 2-2. Figure 2-3. Figure 2-4. Figure 2-5. Identifiers กฎสำหรับ Identifier ตัวอักษรแรกจะตัองเป็น A-Z หรือ a-z หรือ _ (underscore) Identifier จะประกอบด้วยตักอักษร ตัวเลข และ underscores
E N D
Chapter 2 Introduction to The C++ Language
Identifiers • กฎสำหรับ Identifier • ตัวอักษรแรกจะตัองเป็น A-Z หรือ a-z หรือ _ (underscore) • Identifier จะประกอบด้วยตักอักษร ตัวเลข และ underscores • Identifier จะต้องไม่ซ้ำกับคำสงวน
Data Types • Set of Values • Set of Operations
Variables • Variable Declaration • TypeVariableName • เช่น intiVar ; • float fVar ; • char c ;
int count =0 ; // variable declaration and initialize int a, b=0; Variable Initialization
Integer constants123, -10 Float constants0.0 , 1.5 Character constantsA character constant is enclosed in single quotes.‘a’ , ‘h’ , ‘c’ Constants
Figure 2-10 String Constants
Figure 2-12 cin >> a Standard Output The standard output object in C++ is cout (console output). การส่งข้อมูลให้ cout จะใช้ insertion operator (<<)