Data Types - Computer for Competition Exams

Data Types

Data types specify how we enter data into our programs and what type of data we enter. C language has some predefined set of data types to handle various kinds of data that we use in our program. Size of variables, constants and array are determined by data types.

C language supports 4 different type of data types : 

  • Basic Data Types : These are fundamental data types in C namely : Integer types, Floating-Point types

  • Void Data Type : void

  • Derived Data Types : They include (a) Pointer types, (b) Array types, (c) Structure types, (d) Union types and (e) Function types

  • Enumeration Data Type : enum

Types
Data Types
Basic data typesInteger types, Floating types
Void data typevoid
Derived data typepointer, array, structure, union
Enumeration data typeenum

Integer Types : 

Integer type consists int and char data type. Storage size and Range are given below of these data types - 

  • Integer (int) : Integer are used to store whole numbers.The storage size of int data type is 2 or 4 or 8 bytes. It varies upon the processor in the CPU that we use. If we are using 16 bit processor, 2 bytes of memory will be allocated for int data type.


TypeSize(bytes)Range
int or signed int2-32,768 to 32767
unsigned int20 to 65535
short int or signed short int1-128 to 127
unsigned short int10 to 255
long int or signed long int4-2,147,483,648 to 2,147,483,647
unsigned long int40 to 4,294,967,295

  • Character (char) : Character types are used to store characters value. It allows a variable to store only one character. 



TypeSize(bytes)Range
char or signed char1-128 to 127
unsigned char10 to 255

Floating Types :

Floating type consists float and double data type. Storage size and Range are given below of these data types -

  • Float (float) : float data type allows a variable to store decimal values.

  • Double (double) : double data type is same as float which allows up-to 10 digits after decimal. 

TypeSize(bytes)Range
Float43.4E-38 to 3.4E+38
double81.7E-308 to 1.7E+308
long double103.4E-4932 to 1.1E+4932

Void Data Type : 

void type means no value. This is usually used to specify the type of functions.
  • Function returns as void
  • Function arguments as void
  • Pointers to void

Enumeration :

Enumeration data type consists of named integer constant as a list. It start with 0 by default and value is incremented by 1 for sequential identifier in the list.

Syntax :
enum identifier [optional {enumerator-list}];
Data Types Data Types Reviewed by Go Programming on July 16, 2017 Rating: 5
Powered by Blogger.