Chapter 3 Operators and Expressions Windows Programming C

  • Slides: 6
Download presentation
Chapter 3 Operators and Expressions Windows Programming, C. -S. Shieh, KUAS EC, 2005 1

Chapter 3 Operators and Expressions Windows Programming, C. -S. Shieh, KUAS EC, 2005 1

3. 2 Naming Rules for Identifiers • • • Consist of A-Z, a-z, 0

3. 2 Naming Rules for Identifiers • • • Consist of A-Z, a-z, 0 -9, and _. First character must not be 0 -9. No confliction with reserved words. Case sensitive. No Chinese. Windows Programming, C. -S. Shieh, KUAS EC, 2005 2

3. 3 Basic Data Types • C++ Builder Basic Data Types – char, int,

3. 3 Basic Data Types • C++ Builder Basic Data Types – char, int, long, float, double – bool: true or false • Ansi. String Type – There is no string type in C, only array of char. – Ansi. String type makes string manipulation easy. Ansi. String x, y, z; x=”Hello”; y=”world!”; z=x+”, ”+y; Windows Programming, C. -S. Shieh, KUAS EC, 2005 3

3. 4 C++ Operators • Arithmetic: +, -, *, /, % • Assignment: •

3. 4 C++ Operators • Arithmetic: +, -, *, /, % • Assignment: • =, +=, -=, *=, /=, %=, &=, |= • • Relational: ==, !=, <, >, <=, >= Logical: &&, ||, ! Bit-wise logic operator: &, |, ~ Increment and decrement: ++, -Windows Programming, C. -S. Shieh, KUAS EC, 2005 4

3. 5 Data Representations • ASCII – American Standard Code for Information Interchange –

3. 5 Data Representations • ASCII – American Standard Code for Information Interchange – One byte per character • Chinese Big-5 – Two byte per Chinese character Windows Programming, C. -S. Shieh, KUAS EC, 2005 5

3. 6 Number Systems • Position-Weighted System – Decimal • 12. 34 – Binary

3. 6 Number Systems • Position-Weighted System – Decimal • 12. 34 – Binary • (10. 101)2=2. 625 – Hexadecimal • (1 A. 2 B)16=26. 16796875 Windows Programming, C. -S. Shieh, KUAS EC, 2005 6