Chapter Summary

I l @ ve RuBoard

Chapter 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. ANSI C enables you to use signed char and unsigned char to explicitly specify which you want. The other integer types include short , int , long , and the C9X-proposed 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 with ANSI C you can use the unsigned keyword to create the corresponding unsigned types: unsigned short , unsigned int , and unsigned long . K&R C recognizes only unsigned int from this trio. The C9X committee proposes adding unsigned long long to the list.

The three floating-point types are float , double , and, new with ANSI C, long double . Each is at least as large as the preceding type.

Integers can be expressed in decimal, octal, or hexadecimal form. A leading 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.

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 .

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 .

I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net