C-Tokens
Identifier
Identifier Rules
Variable
Syntax - variable
Syntax :
datatype name = <value>;
Ex: int x=4;
Keywords
Integer-constant
– The suffix U (or u) forces the constant to be unsigned. It is unsigned long if the value of the number itself is greater than decimal 2,147,483,647, regardless of which base is used.
– The suffix L (or l) attached to any constant forces the constant to be represented as a long.
– UL or ul : unsigned long
character-constant
Float & Enumeration Constant
Floating constant
Why data type?
Variable
------- data type
int
Type Specifiers:
char double enum
int struct typedef
float union void
Special type specifiers:
Special Type Specifiers
Signed & unsigned
Long & short
- Identifier
- Variable
- Constants
- Keywords
- Data types
Identifier
- Simply references to memory locations,which can hold values (data).
- Formed by combining
- Letters (both upper and lowercase)
- Digits (0–9)
- Underscore ( _ )
Identifier Rules
- The first character of an identifier must be a letter,an underscore ( _ ) also counts as a letter
- The blank or white space character(ascii value) is not permitted in an identifier.
- Can be any length. Internal identifier (do not have the external linkage) such as preprocessor macro names at least the first 31 characters are significant, also implementation dependent.
- Reserved words/keywords and characters such as main and # also cannot be used.
Variable
- Identifier that value may change during the program execution.
- Initializing a variable means, give a value to the variable, that is the variable’s initial value and can be changed later on.
Syntax - variable
- Type
- Name
- Value
Syntax :
datatype name = <value>;
Ex: int x=4;
Keywords
C - keyword List |
- Keywords are the words whose meaning has already been explained to the ‘C’ compiler.
- The keywords are also called as reserved words.
- There are 32 keywords available in ‘C’.
- integer-constant
- character-constant
- floating-constant
- enumeration-constant
Integer-constant
- consisting of a sequence of digits
- number preceded by 0 : octal number
- number preceded by 0x: hexadecimal
- integer constant may be suffixed by letter
– The suffix U (or u) forces the constant to be unsigned. It is unsigned long if the value of the number itself is greater than decimal 2,147,483,647, regardless of which base is used.
– The suffix L (or l) attached to any constant forces the constant to be represented as a long.
– UL or ul : unsigned long
character-constant
- sequence of one or more characters enclosed in single quotes Ex: ‘a’
- Character constants do not contain the newlines character in order to represent them following escape sequences may be used
- There is an extended set of characters that cannot be represented in the char type.
- A constant in this extended set is written with a preceding L
Float & Enumeration Constant
Floating constant
- floating constant consists of a decimal part and a fraction part.
- A floating-point constant that is not suffixed is of type double.
- F or f for a float and L and I for long double.
- Identifiers declared as enumerators are constants of type int.
- Enumeration constants are identifiers defined in enum type declarations
Why data type?
Variable
- VALUE (100, 1000 etc…)
- TYPE (char, int etc…)
------- data type
int
- int will normally be the natural size for aparticular machine
- To develop portable programs, two suffixes are used : “short” and “long”
- Short is often 16 bits, long 32 bits
Type Specifiers:
char double enum
int struct typedef
float union void
- signed short
- unsigned long
Type qualifiers
- Const
- Volatile
Special Type Specifiers
Signed & unsigned
- shows effect on sign of the variable.
- can be used with int and char.
- cannot be used with float and double.
Long & short
- shows effect on size of the variable.
- can be used with int and char.
- cannot be used with float and double.
- long can be used with double.
No comments:
Post a Comment