Sams Teach Yourself C in 21 Days

(singke) #1

  • The size of a charis one byte.

  • The size of a shortis less than or equal to the size of an int.

  • The size of an intis less than or equal to the size of a long.

  • The size of an unsignedis equal to the size of an int.

  • The size of a floatis less than or equal to the size of a double.


48 Day 3

Table 3.2 listed the common keyword used to identify the different variable
types. The following table (Table 3.3) lists the full name of each of the data
types.
As you can see from this table, shortandlongtypes are really just variations
on the inttype. Most programmers don’t use the full name of the variable
types, rather thy use the shorter version.

Note


TABLE3.3 Full names of data types
Full name commonly used keyword
char signed char
short signed short int
int signed int
long signed long int
long long signed long long int
unsigned char unsigned char
unsigned short unsigned short int
unsigned int unsigned int
unsigned long unsigned long int
unsigned long long unsigned long long int

Variable Declarations ......................................................................................


Before you can use a variable in a C program, it must be declared. A variable declaration
tells the compiler the name and type of a variable. The declaration may also initialize the
variable to a specific value. If your program attempts to use a variable that hasn’t been
declared, the compiler generates an error message. A variable declaration has the follow-
ing form:
typename varname;

06 448201x-CH03 8/13/02 11:14 AM Page 48

Free download pdf