The declaration of a variable will assign storage for the variable and define the type of data that will be held in the location.
So what data types are available?
int | float | double | char | void | enum |
Please note that there is not a boolian data type. C does not have the traditional view about logical comparison, but thats another story.
{ int Count; Count =index.html 5; }
{ float Miles; Miles =index.html 5.6; }
{ double Atoms; Atoms =index.html 2500000; }
{ char Letter; Letter =index.html 'x'; }
short int <=index.html LONGWhat this means is that a 'short int' should assign less than or the same amount of storage as an 'int' and the 'int' should be less bytes than a 'long int'. What this means in the real world is:
short int - 2 bytes (16 bits) int int - 2 bytes (16 bits) long int - 4 bytes (32 bits) signed char - 1 byte (Range -128 ... +127) unsigned char - 1 byte (Range 0 ... 255) float - 4 bytes double - 8 bytes long double - 8 bytesThese figures only apply to todays generation of PCs. Mainframes and midrange machines could use different figures, but would still comply with the rule above.
You can find out how much storage is allocated to a data type by using
the sizeof operator.
const float pi=3.14159;
pi cannot be changed at a later time within the program.
Another way to define constants is with the
#define preprocessor which
has the advantage that it does not use any storage (but who counts bytes
these days?).
Qualifiers
The const qualifier is used to tell C that the variable value can not
change after initialisation.
See also:
Data type conversion
typedef keyword.
Top | Master Index | Keywords | Functions |