Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Data Types

Unlike humans, a computer does not know the difference between "1234" and "abcd." A data
type is a classification that dictates what a variable or object can hold in computer
programming. Data types are an important factor in virtually all computer programming
languages, including C#, C++, JavaScript, and Visual Basic. When programmers create computer
applications, both desktop and web-based, data types must be referenced and used correctly to
ensure the proper result and an error-free program.

Data type is an attribute associated with a piece of data that tells a computer system how to
interpret its value. Understanding data types ensures that data is collected in the preferred
format and the value of each property is as expected.

Common data types

1. Integer (int)

It is the most common numeric data type used to store numbers without a fractional
component (-707, 0, 707).

2. Floating Point (float) / Real number

It is also a numeric data type used to store numbers that may have a fractional component like
monetary values do (707.07, 0.7, 707.00).

3. Character (char)

It is used to store a single letter, digit, punctuation mark, symbol, or blank space.

4. String (str or text)

It is a sequence of characters and the most commonly used data type to store text. Additionally,
a string can also include digits and symbols, however, it is always treated as text.

eg: "RAM", "Kathmandu"

A phone number is usually stored as a string (+1-999-666-3333) but can also be stored as an
integer (9996663333).

5. Boolean (bool)

It represents the values true and false. When working with the boolean data type, it is helpful
to keep in mind that sometimes a boolean value is also represented as 0 (for false) and 1 (for
true).

You might also like