What is Data Type and Why Data Type Need?
In programming there are different types of data used for example 987,876.34, xyz, Hello World, %, # etc.
As a human being we can differentiate that these all data are different but machine can’t differentiate data, so, to differentiate data they have been categorized in different categories which are called data type.
ANSI C provides three types of data types:
1. Primary (Built-in) DataTypes:
void, int, char, double and float.
Array , References, and Pointers.
3.User Defined DataTypes:
Structure , Union, and Enumeration.
1. Following are Primary Data Types in C:
– means nothing. void is always used with main function. That mean void
function does not return any value.
– 0-9 digit (combination) i.e. 99999 , 10 , 0 , 23456
– Real Number i.e 78.91
-There are 4 sub categories:
o other symbols
- Note: character contains only single value
– Is collection of character but C language does not allow to declare
string as a data type.
Data Type is always used in variable declaration in beginning in void main.
data type name;
2. Following are Derived Data Types in C:
Derived Data type is based on Primary data type.
Arrays – Arrays are sequences of data items having homogeneous values.
References – Function pointers allow referencing functions with a particular signature.
Pointers – These are powerful C features which are used to access the memory address
3. Following are User Defined Data Types in C:
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:
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.
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.
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.
To learn more about C Language at TCCI
Visit @ http://tccicomputercoaching.com/
Call @ 9825618292