Xem mẫu

Chapter 3 – Variables and Arithmetic Operations Variable Rules Must declare all variable names – List name and type Keep length to 31 characters – Older compiler restriction Give numeric values to variables with assignment statement variable_name = value; assignment operator Lesson 3.1 Naming Identifiers First character must be letter – a­z, A­Z or _ Other characters – letters (a­z, A­Z, _ ) or digits 0­9 Cannot use C++ keywords (reserved words) Cannot have blank within identifies Lesson 3.1 Keywords Words with special meaning to C++ Also includes alternative representations of certain operators and punctuators Full listing in Table 3.1 Examples: – auto, bool, float, inline, union, delete – namespace, private, void Lesson 3.1 Declaring Variables Variables MUST be declared List name and data type Variables of same type may be declared in same statement (separate by comma) Causes C++ compiler to know size of space to be reserved for storing variable’s value data type double radius, diameter;variable names separator Lesson 3.1 ... - tailieumienphi.vn
nguon tai.lieu . vn