Basic Data Type


Keyword char is used for declaring character type variables. For example,

char test = 'h';

The size of the character variable is 1 byte.

Basic Data Type

float and double

float and double are used to hold real numbers.

float salary;
double price;

In C, floating-point numbers can also be represented in exponential. For example,

float normalizationFactor = 22.442e2;

What’s the difference between float and double?

The size of float (single precision float data type) is 4 bytes. And the size of double (double precision float data type) is 8 bytes.

Basic Data Type


Integers are whole numbers that can have both zero, positive and negative values but no decimal values. For example, 0-510

We can use int for declaring an integer variable.

int id;

Here, id is a variable of type integer.

You can declare multiple variables at once in C programming. For example,

int id, age;

The size of int is usually 4 bytes (32 bits). And, it can take 232 distinct states from -2147483648 to 2147483647.

Basic Data Type

Basic Data Types

There are the following data types in C language.

TypesData Types
Basic Data Typeint, char, float, double
Derived Data Typearray, pointer, structure, union
Enumeration Data Typeenum
Void Data Typevoid

The basic data types are integer-based and floating-point based. C language supports both signed and unsigned literals.

The memory size of the basic data types may change according to 32 or 64-bit operating system.

Let’s see the basic data types. Its size is given according to 32-bit architecture.

Data TypesMemory SizeRange
char1 byte−128 to 127
signed char1 byte−128 to 127
unsigned char1 byte0 to 255
short2 byte−32,768 to 32,767
signed short2 byte−32,768 to 32,767
unsigned short2 byte0 to 65,535
int2 byte−32,768 to 32,767
signed int2 byte−32,768 to 32,767
unsigned int2 byte0 to 65,535
short int2 byte−32,768 to 32,767
signed short int2 byte−32,768 to 32,767
unsigned short int2 byte0 to 65,535
long int4 byte-2,147,483,648 to 2,147,483,647
signed long int4 byte-2,147,483,648 to 2,147,483,647
unsigned long int4 byte0 to 4,294,967,295
float4 byte
double8 byte
long double10 byte
Basic Data Type

Understanding C Datatypes

As the name suggests, a Datatype defines the type of data being used. Whenever we define a variable or use any data in the C language program, we have to specify the type of the data, so that the compiler knows what type of data to expect.

For example, you may want to use a number like 12100, or a decimal point number like 99.9510.5, or a text, like “Studytonight”, all these values are handled differently by the C language compiler, hence, we use data types to define the type of data used in any program.

C Datatypes

Broadly, there are 5 different categories of data types in the C language, they are:

Basiccharacter, integer, floating-point, double.
DerivedArray, structure, union, etc.
Bool typetrue or false
voidEmpty value

C Primary Data types:

The C language has 5 basic (primary or primitive) 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 121001000, etc.
  3. Floating-point – Decimal point or real numbers values like 99.910.5, etc.
  4. Double – Very large numeric values which are not allowed in Integer or Floating point type.
  5. Void – This means no value. This data type is mostly used when we define functions.

There are different keywords to specify these data types, the keywords are: