- a character constant can take one of four forms:
- a single character enclosed in a pair of single quotes, like
`'a'`

or`'$'`

- a backslash character followed by one to three octal digits (any digit
from 0 to 7), like
`'\7'`

or`'\007'`

- a backslash character followed by an 'x' (but
**not**'X') and one or two hexadecimal digits (any digit from 0 to 9 as well as any letter from 'a' to 'f' or from 'A' to 'F'), like`'\xa0'`

or`'\03F'`

- a backslash character followed by one of eleven special characters,
which are interpreted like:
\a alert (bell) character \b backspace \f formfeed \n newline \r carriage return \t horizontal tab \v vertical tab \\ backslash \? question mark \' single quote \" double quote

- a single character enclosed in a pair of single quotes, like
- ANSI C also allows
`L`

to define a*character-constant**wide character*, using a group of characters and escape codes to form a single multibyte character for alphabets (Japanese, Chinese, etc) with more than 256 symbols. - some implementations may also allow multi-character constants, where
a constant like
`'PICT'`

is packed into a single 32 bit word- the byte order of a packed multi-character constant is machine-dependent and thus non-portable

- Integer constants can be one of the different bases:
- a number starting with
a digit from 1 to 9 followed only by digits from 0 to 9
is a decimal (base 10) constant, like
`1`

or`54321`

- if a number begins with '0x' or '0X' and is followed by digits from
0 to 9 and letters from a to f or from A to F, it is
interpreted as a hexadecimal (base 16) constant, like
`0xbeef`

or`0XDEAD`

- if a number begins with 0 and is followed by digits from
0 to 7, it is interpreted as an octal (base 8) constant, like
`07`

(which is the same as`7`

) or`0111`

(which is**NOT**the same as`111`

)

- a number starting with
a digit from 1 to 9 followed only by digits from 0 to 9
is a decimal (base 10) constant, like
- integer constants in any of the three bases may be followed by an 'l'
or 'L' to indicate a
`long`

constant, like`17l`

or`0xFfL`

- in ANSI C, an integer constant may be followed by:
- a 'u' or 'U' to indicate an
`unsigned`

constant, like`33u`

- a 'ul' or 'UL' to indicate an
`unsigned long`

constant, like`32767ul`

- a 'u' or 'U' to indicate an
- an integer constant takes on the minimum type necessary to be accurately
represented, (possibly) starting as
`int`

and increasing from`long`

to`unsigned long`

- octal and hexadecimal constants, and (in ANSI C) constants ending with
a 'u' or 'U' may also be
`unsigned`

(which can hold larger values than`int`

but may have fewer bytes than`long`

)

- octal and hexadecimal constants, and (in ANSI C) constants ending with
a 'u' or 'U' may also be
- in ANSI C, 0 is always
`unsigned`

(perhaps to reduce ambiguity on machines with one's complement arithmetic) - as an example, if an
`int`

is 16 bits wide and a`long`

is 32 bits wide, the following ranges would apply:Range Decimal Octal/Hexadecimal 0 unsigned unsigned 1-32767 int int 32768-65535 long unsigned 65536-2147483647 long long 2147483648-429497295 unsigned long unsigned long 429497296-? ??? ???

- a floating-point constant can take one of two forms:
- a group of digits from 0 to 9 which includes a single period, like
`3.141593`

,`0.`

or`.1`

- a group of digits from 0 to 9, possibly containing a period,
followed by 'e' or 'E' and an exponent, like
`1.0e3`

,`2.593e+7`

or`3141593e-6`

- a group of digits from 0 to 9 which includes a single period, like
- in ANSI C, a floating-point constant may be followed by:
- an 'f' or 'F' to indicate a
`float`

constant, like`35.79f`

- Note that
`123f`

is an error, because`123`

is not a floating-point constant

- Note that
- a 'l' or 'L' to indicate a
`long double`

constant, like`35.79l`

- an 'f' or 'F' to indicate a
- in the absence of a 'f' or 'l' qualifier, floating-point
constants are assumed to be of datatype
`double`

, which should be the most efficient floating-point datatype