Data Types in Programing Language 

A data type is a classification of types of data that determines the possible values for that type, the operations that can be performed on it, and the way values of that type can be stored. Here are some examples of common data types:

data types


  • Integer:

  • A whole number, positive or negative. Examples: -5, 0, 100

  • Float: A number with a decimal point. Examples: -5.5, 0.0, 3.14159
  • Boolean: A value that is either True or False.
  • String: A sequence of characters. Examples: "hello", "goodbye", "12345"
  • List: An ordered collection of items. Examples: [1, 2, 3], ['a', 'b', 'c']
  • Dictionary: A collection of key-value pairs. Example: {'name': 'John', 'age': 30}

Here is an example of how you might use these data types in a program:

int age = 30;
Float cgpa = 3.7;
Bolean is_graduated = True;
string name = "Nauman"
list grades = [90, 80, 70, 60];
string student = {'name': name, 'age': age, 'cgpa': cgpa}; print(name + " is " + str(age) + " years old and has a CGPA of " + str(cgpa)) if is_graduated:
print(name + " has graduated!");
else:
print(name + " has not graduated yet."); total_grade = 0;
for grade in grades:
total_grade += grade;
average_grade = total_grade / len(grades);
print("Average grade: " + str(average_grade)); print("Student information:");
for key in student:
print(key + ": " + str(student[key]));

Table for ranges of data types

Data typeValue range
int (integer)-2147483648 to 2147483647
long-9223372036854775808 to 9223372036854775807
floatApproximate range of ±1.8 x 10^308 with 7 decimal digits of precision
doubleApproximate range of ±1.7 x 10^308 with 15 decimal digits of precision

Note: that these ranges may vary depending on the programming language and the specific implementation of the data type.

It's also worth noting that some languages may have additional data types for representing numbers, such as short, byte, and unsigned int. These types may have smaller ranges than the ones listed above, but they may also be able to represent numbers more efficiently in terms of memory usage.

Different programming languages may have different data types for representing integers, and each data type may have a different range of values that it can represent. Here are some examples of integer data types in some common programming languages:

  • C: int, long, long long
  • C++: int, long, long long
  • Java: int, long
  • Python: int, long
  • JavaScript: Number (integers and floating-point numbers are represented using the same data type)
  • C#: int, long

In most programming languages, the int data type is a fixed-precision number that can represent a range of values that is determined by the number of bits it uses to store the value. For example, an int in C or C++ is usually a 32-bit (4-byte) value, while an int in Java is a 32-bit value on most platforms, but it may be a 64-bit value on some platforms.

The long data type is usually a larger integer data type that can represent a wider range of values than the int data type. For example, a long in C or C++ is usually a 64-bit (8-byte) value, while a long in Java is a 64-bit value on all platforms.

In some programming languages, there may be additional integer data types, such as short, which is a smaller integer data type that can represent a smaller range of values than int, but may be able to represent numbers more efficiently in terms of memory usage.

primary data

A primary data type is a basic data type that is built into a programming language and is not derived from any other data type. Here are some examples of primary data types in some common programming languages:


  • C: char, int, float, double
  • C++: bool, char, int, float, double
  • Java: boolean, char, byte, short, int, long, float, double
  • Python: int, float, bool, str
  • JavaScript: Number, String, Boolean, Symbol
  • C#: bool, byte, char, decimal, double, float, int, long, sbyte, short, uint, ulong, ushort

  • Complex/Secondary Data Types

Complex data structures are data types that are used to store and organize large amounts of data in a structured way. These data types are often built from simpler data types, such as primary data types like integers and strings.

Some examples of complex data structures include:

Secondary Data Types

  • Arrays: An array is a data structure that stores a fixed-size collection of elements of the same data type. Arrays are often used to store lists of items, such as a list of names or a list of numbers.

  • Lists: A list is a data structure that stores an ordered collection of elements. Lists are similar to arrays, but they can grow or shrink in size as needed. Lists are often used to store collections of items that are likely to change in size, such as a list of users or a list of tasks.

  • Objects: An object is a data structure that stores a collection of properties, each of which has a name and a value. Objects are often used to represent real-world entities, such as a person or a product, and are a fundamental building block of object-oriented programming.

    • ets: A set is a data structure that stores a collection of unique elements. Sets are often used to store collections of items that are not meant to contain duplicates, such as a list of unique user IDs or a list of distinct words in a document.

    • Maps: A map is a data structure that stores a collection of key-value pairs. Maps are often used to store data that needs to be quickly retrieved using a unique key, such as a dictionary or a lookup table.

    These are just a few examples of complex data structures, and there are many others that are used in different programming languages and contexts.