words or keywords cannot be used as an identifier name. Chapter Page - - As per ANSI standards, C++ places no limit on its length and therefore all the characters are significant. Identifiers Valid / Invalid Reason for invalid Num Valid NUM Valid _add Valid Valid tamilMark Valid num-add Invalid Contains special character (-) this Invalid This is one of the keyword. Keyword cannot be used as identifier names.
2myfile Invalid Name must start begins with an alphabet or an underscore • You may use an underscore in variable names to separate different parts of the name (eg: is a valid identifier where as the variable called total sales is an invalid identifier). • You may use capital style notation, such as tamilMark ie. capitalizing the first letter of the second word. .
. Literals (Constants) Literals are data items whose values do not change during the execution of a program. Therefore Literals are called as Constants. C++ has several kinds of literals: Numeric Constants Integer constants Boolean Constants Literals (Constants) Real Constants Character Constants String Literals Figure .
Types of Constants Numeric Constants: As the name indicates, the numeric constants are numeric values, which are used as constants. Numeric constants are further classified as: . Integer Constants (or) Fixed point constants. .
Real constants (or) Floating point constants. ( ) Integer Constants (or) Fixed point constants Integers are whole numbers without any fractions. An integer constant must have at least one digit without a decimal point. It may be signed or unsigned.
Signed integers are considered as negative, commas and blank spaces are not allowed as part of it. In C++, there are three types of integer constants: (i) Decimal (ii) Octal (iii) Hexadecimal (i) Decimal Any sequence of one or more digits ( …. ) Valid Invalid , (Comma is not allowed) - (Blank space is not allowed) . $ (Special Character not allowed) If you assign .
as an integer decimal constant, the compiler will accept only the integer portion of . ie. . It will simply ignore .