Data Type in C Language-tccicomputercoaching.com

Page 1

Data Type in C Languagetccicomputercoaching.com 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.

2.

Derived DataTypes: Array, References, and Pointers.

3.

User Defined DataTypes: Structure, Union, and Enumeration.

1. Following are Primary Data Types in C:


   

 

void - means nothing. void is always used with main function. That mean void function does not return any value. int - 0-9 digit (combination) i.e. 99999 , 10 , 0 , 23456 float - Real Number i.e 78.91 char -There are 4 sub categories: o 0-9 o a-z o A-Z o other symbols Note: character contains only single value string - 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; For example, int rollno; float salary; char code; 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: 

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. 

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. To learn more about C Language at TCCI Visit @ http://tccicomputercoaching.com/ Call @ 9825618292


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.