Learn C Language

Learn C Programming Language Step By Step. It’s easy to learn c programming language with real-life examples and hands-on. We are trying our best to deliver quality content.

C Data Types

« Previous Page                                                                                                                              Next Page »

Data types in C refers to an extensive system used for declaring variables and functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern for stored data is interpreted.

Data types in C or any programming language is something which specifies how to enter data into programs and what type of data to enter. C language has some predefined set of data types to handle various kinds of data that you can use in your program. These data types have different storage capacities.

Types Of Data types

There are various statements on how many Data types in C to be considered. In my opinion, there are four Data types in C that you should consider.

  • Basic Data Types
  • Derived Data Types
  • Enumeration Data Types
  • Void Data Types

But, you can categorise these four data types in two broad category, PRIMARY and Derived Data types in C.

Basic Datatypes

Basic Datatypes are arithmetic types and are further classified into integer types and floating-point types.

Enumerated Datatypes

They are again arithmetic types and they are used to define variables that can only assign certain discrete integer values throughout the program.

Void Datatypes

The type specifier void indicates that no value is available.

Derived Datatypes

Derived data types are nothing but primary data types but a little twisted or grouped together like an arraystructureunion, and pointer.

The array types and structure types are referred collectively as the aggregate types. The type of a function specifies the type of the function’s return value. We will see the basic types in the following section, whereas other types will be covered in the upcoming chapters.

Character Type

Character types are used to store the characters’ value.

Size and range of Integer type on a 16-bit machine

Type Size(bytes) Range
char or signed char 1 -128 to 127
unsigned char 1 0 to 255

Integer Types

The following table provides the details of standard integer types with their storage sizes and value ranges −


Type Storage size Value range
char 1 byte -128 to 127 or 0 to 255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 2 or 4 bytes -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned short 2 bytes 0 to 65,535
long 4 bytes -2,147,483,648 to 2,147,483,647
unsigned long 4 bytes 0 to 4,294,967,295

To get the exact size of a type or a variable on a particular platform, you can use the sizeof operator. The expressions sizeof(type) yields the storage size of the object or type in bytes. Given below is an example to get the size of int type.

When you compile and execute the above program, it produces the following result on Windows on which I am running:

OUTPUT: Storage size for int: 4

Floating Point Data types

Floating types are used to store real numbers.

Size and range of Integer type on a 16-bit machine

Type Size(bytes) Range
Float 4 3.4E-38 to 3.4E+38
double 8 1.7E-308 to 1.7E+308
long double 10 3.4E-4932 to 1.1E+4932

The header file float.h defines macros that allow you to use these values and other details about the binary representation of real numbers in your programs.

OUTPUT: Storage size for float: 4

Void Data types

Function returns as void

There are various functions in C which do not return any value or you can say they return void. A function with no return value has the return type as void. For example, void exit (int status);

Function arguments as void

There are various functions in C which do not accept any parameter. A function with no parameter can accept a void. For example, int rand(void);

Pointers to void

A pointer of type void * represents the address of an object, but not its type. For example, a memory allocation function void *malloc( size_t size ); returns a pointer to void which can be casted to any data type.

Top Book Suggestion

The two books on C Programming Language that I Personally Recommend. I really loved reading these books. These books are listed for quality content, easy steps, and affordable price. You can get it from Amazon and Flipkart. 

Check The Price On Amazon:

1. C Programming Beginner’s Guide

2. Head First C: A Brain-Friendly Guide

Check The Price On Flipkart:

1. Introduction to C Programming 

2. Head First C: A Brain-Friendly Guide

« Previous Page                                                                                                                              Next Page »

Buy Premium Courses At Lowest Price. Become A Certified Developer Today!

Best Books Selected by Our Experts

Buy Premium Projects At Lowest Price

Ebooks Written by Our Experts


Buy Premium Courses At Lowest Price. Grab Golden Opportunity To Become A Certified Developer Today!

Useful Links

Pin It on Pinterest

Share This