Published by: Nuru
Published date: 21 Jun 2021
The data type is an attribute that describes the nature of data to be stored in memory. C language is rich in its data types. There are other varieties of data types available in C, each of which may be represented differently within the computer’s memory. These varieties of data types allow the programmer to select the type needed in his/her application. There are various types of data. For e.g., data 10 and 10.5 are of different types. The data 10 is an integer while 10.5 is a fractional number.
ANSI C supports 3 classes of data types:
The primary data types are categorized into five types:
I. Integer type (int)- a whole number
II. Floating point type (float)- a number with a fraction part
III. Double precision floating type (double)-a number with double precise value than float
IV. Character type (char)-a single character
V. Void type (void)-holds no value used to specify the type of function or what it returns
C supports three derived data types:
C allows the feature called type definition which allows programmers to define their identifier that would represent an existing data type. There are three such types:
Structure | It is a package of variables of different types under a single name. This is done to handle data efficiently. "struct" keyword is used to define a structure. |
Union | These allow storing various data types in the same memory location. Programmers can define a union with different members, but only a single member can contain a value at a given time. A keyword union is used. |
Enum | Enumeration is a special data type that consists of integral constants, and each of them is assigned with a specific name. "enum" keyword is used to define the enumerated data type. |
some of the most used data types and their sizes are given below:
An escape sequence is a non-printing character in C. it is a character combination consisting of a backslash(\)followed by a letter or digit. The escape sequence is useful for formatting input and output.
some of the common escape sequence characters along with their function are: