Datatypes refer to sytem used for declaring and using variables or functions of different type. The type of variable determines space it requires.
The types in C can be categorized in following: -
Type |
Description |
Basic Type |
Standard and extended integer, complex and floating types. |
Enumerated Type |
Arithmetic types and are used to define variables that can only be assigned certain discrete integer values through out the program. |
The type void |
Tye type void indicates “no” value is available. |
Derived Type |
Pointer, Array, Structure, Union and Functions. |
Add a comment
The constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals.
Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are also enumeration constants as well.
The constants are treated just like regular variables except that their values cannot be modified after their definition.
Note: - we will cover secondary Constants in sebsequent chapters.
Add a commentThere are two simple ways in C to define constants:
1. Using #define preprocessor.
2. Using const keyword.
C Keywords
Keywords are the words whose meaning has already been explained to the C compiler (or
in a broad sense to the computer). The keywords cannot be used as variable names
because if we do so we are trying to assign a new meaning to the keyword, which is not
allowed by the computer. Some C compilers allow you to construct variable names that
exactly resemble the keywords. However, it would be safer not to mix up the variable
names and the keywords. The keywords are also called ‘Reserved words’.
There are only 32 keywords available in C. Figure gives a list of these keywords for your
ready reference. A detailed discussion of each of these keywords would be taken up in later
chapters wherever their use is relevant
Add a comment
A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.
Type |
Description |
char |
Typically a single octet(one byte). This is an integer type. |
int |
The most natural size of integer for the machine. |
float |
A single-precision floating point value. |
double |
A double-precision floating point value. |
void |
Represents the absence of type. |