Summary
C has a variety of data types. The basic types fall into two categories: integer types and floating-point types. The two distinguishing features for integer types are the amount of storage allotted to a type and whether it is signed or unsigned. The smallest integer type is char, which can be either signed or unsigned, depending on the implementation. You can use signed char and unsigned char to explicitly specify which you want, but that’s usually done when you are using the type to hold small integers rather than character codes. The other integer types include the short, int, long, and long long type. C guarantees that each of these types is at least as large as the preceding type. Each of them is a signed type, but you can use the unsigned keyword to create the corresponding unsigned types: unsigned short, unsigned int, unsigned long, and unsigned long long. Or you can add the signed modifier to explicitly state that the type is signed. Finally, there is the _Bool type, an unsigned type able to hold the values 0 and 1, representing false and true.
The three floating-point types are float, double, and, since C90, long double. Each is at least as large as the preceding type. Optionally, an implementation can support complex and imaginary types by using the keywords _Complex and _Imaginary in conjunction with the floating-type keywords. For example, there would be a double _Complex type and a float _Imaginary type.
Integers can be expressed in decimal, octal, or hexadecimal form. A leading 0 indicates an octal number, and a leading 0x or 0X indicates a hexadecimal number. For example, 32, 040, and 0x20 are decimal, octal, and hexadecimal representations of the same value. An l or L suffix indicates a long value, and an ll or LL indicates a long long value.
Character constants are represented by placing the character in single quotes: 'Q', '8', and '$', for example. C escape sequences, such as '\n', represent certain nonprinting characters. You can use the form '\007' to represent a character by its ASCII code.
Floating-point numbers can be written with a fixed decimal point, as in 9393.912, or in exponential notation, as in 7.38E10. C99 and C11 provide a third exponential notation using hexadecimal digits and powers of 2, as in 0xa.1fp10.
The printf() function enables you to print various types of values by using conversion specifiers, which, in their simplest form, consist of a percent sign and a letter indicating the type, as in %d or %f.