Home Show/Hide Menu
C Tutorials
➜ C Language
  - Features of C
  - First C Program
  - Compilation in C
  - C Character Set
  - Tokens
  - Keywords
  - Identifiers
  - Constants
  - Operators
  - Data Types
  - Variables
  - Type Casting
  - Comments
  - Input/Output
  - Escape Sequence
  - Programming Errors
➜ Control Statements
  - if Statement
  - if-else Statement
  - Nested if-else
  - else-if
  - switch Statement
  - Loop
  - while loop
  - do while loop
  - for loop
  - break
  - continue & goto
  - Nested Loop
  - Infinite Loop
➜ Functions
  - What is function
  - Call by Value & Reference
  - Recursive function
  - Storage Classes
➜ Array
  - 1-D Array
  - 2-D Array
  - Return an Array
  - Array to Function
➜ C Pointers
  - Pointers
  - Pointer to Pointer
  - Pointer Arithmetic
  - Dangling Pointers
  - sizeof() operator
  - const Pointer
  - void pointer
  - Dereference Pointer
  - Null Pointer
  - Function Pointer
  - Function pointer as argument
➜ Memory Management
  - Memory Layout of C
  - Dynamic memory
  - calloc()
  - malloc()
  - realloc()
  - free()
➜ Strings
  - gets() & puts()
  - String Functions
  - strlen()
  - strcpy()
  - strcat()
  - strcmp()
  - strrev()
  - strlwr()
  - strupr()
  - strstr()
➜ C Math
  - Math Functions
➜ Enum, Structure & Union
  - Enum
  - Structure
  - typedef
  - Array of Structures
  - Nested Structure
  - Structure Padding
  - Union
➜ File Handling
  - fprintf() fscanf()
  - fputc() fgetc()
  - fputs() fgets()
  - fseek()
  - EOF and feof()
  - fsetpos()
  - tmpfile()
  - rewind()
  - ftell()
  - lseek()
➜ Preprocessor
  - Preprocessor
  - Macros
  - #include
  - #define
  - #undef
  - #ifdef
  - #ifndef
  - #if
  - #else
  - #error
  - #pragma
➜ Command Line
  - Arguments

Data Types in C Language

A data type in C programming specifies the type of variables or functions, so that the compiler knows what type of data and how much space it occupies in storage. C language provides various data-types which allow the programmer to specify the appropriate variable type to set its value.


In the C language, there are five different categories of data types, which are shown below :

  • Basic Data Type - int, char, float, double, void
  • Derived Data Type - array, pointer, structure, union
  • Enumeration Data Type - enum
  • Bool Data Type - true or false

Basic Data Type

The C language has four basic or primary data types, they are:
1. Character - ASCII character set or generally a single alphabet like 'A', 'b', '#', '%' etc.
2. Integer - Used to store whole numbers like 0, 1, 5, 47, 150, 1700, etc.
3. Floating-point - Decimal point or real numbers values like 49.7, 15.9, etc.
4. Double - Very large real numbers which are not allowed in floating point type.
5. Void - It holds no value and generally is used for specifying the type of function or return type.

 Data Types  Storage Size  Value Range 
char 1 byte -128 to 127
  signed char 1 byte -128 to 127
  unsigned char 1 byte 0 to 255
short 2 byte -32,768 to 32,767
  signed short 2 byte -32,768 to 32,767
  unsigned short 2 byte 0 to 65,535
int 2 byte -32,768 to 32,767
  signed int 2 byte -32,768 to 32,767
  unsigned int 2 byte 0 to 65,535
short int 2 byte -32,768 to 32,767
  signed short int 2 byte -32,768 to 32,767
  unsigned short int 2 byte 0 to 65,535
long int 4 byte -2,147,483,648 to 2,147,483,647 
  signed long int 4 byte -2,147,483,648 to 2,147,483,647 
  unsigned long int 4 byte 0 to 4,294,967,295
float 4 byte 1.2E-38 to 3.4E+38
double 8 byte 2.3E-308 to 1.7E+308
long double 10 byte 3.4E-4932 to 1.1E+4932

Derived Data Type

The data-types that are derived from the primitive or built-in data types are referred to as Derived Data Types. Derived data types are nothing but primary data types but a little twisted or grouped together like an array, structure, union, and pointers.


Enumeration Data Type

Enumeration (or enum) is a user defined data type in C. It is mainly used to assign names to integral constants, the names make a program easy to read and maintain. Example :
enum signal {red = 0, yellow = 1, green = 1};


Bool Data Type

A boolean is a data type in the C Standard Library which can store true or false. Every non-zero value corresponds to true while 0 corresponds to false. Example :
bool x=false;



ADVERTISEMENT