information about computer technology and about computer languages.

Tuesday, 9 February 2021

data types in c

 Data Types

The data type specifies the type of data that we stored in a variable. It also defines a set of operations on the data. Every data type requires different amount of memory. The compiler allocates memory space for each variable or constant according to its data type.



Categories of Data Types

C language provides two ways to use data types.

Standard Data Type

C language defines some standard data types. A data type that is predefined in a language is called standard data type. Some example of standard data type is  int, float, long, char etc. 
  • Integer data type
Integer is the numeric value with no decimal point. It is used to store integer value it includes both positive and negative values. For example : 28         20          -32 .
int data type, short data type and unsigned data types takes two bytes in memory. Long data type and unsigned long data type takes four bytes in memory.
  • Floating point data type
The floating point data is a numeric value with decimal point. it includes both positive and negative values. For example : 42.3         -3.3          27.8.
Float data type takes four bytes. double data types takes eight bytes in memory. long double data type takes ten bytes in memory.

  • Double 
it is used to store decimal numbers with double precision.
  • char
Char stores a single characters and requires a single byte of memory . it is the most basic data type in C.



User-defined Data Type

Data types that are defined by user called user-defined data type. C also allows the user to define his own data types.


No comments:

Post a Comment