Topics / Programming / Data Types (in computer programs)

Data Types (in computer programs)

In computer programming, data types are the attributes that specify the type of data that a data structure can hold.

We need to declare a data type for variables and arrays.

Why bother?

It’s important to specify the right data type for your data structures because the program needs to know what type of values an object can store and which operations can be successfully performed using it.

Failure to use the correct data type may result in you losing the ability to perform sorts or calculations using the data.

Common Data Types

The names that we give to certain data types can change from one programming language to another, but here is a list found in many:

Data TypeDescriptionExample Data
IntegerWhole numbers56
BooleanLogical True/FalseTRUE
StringAlphanumeric characters, text“I am a string”
RealNumbers that may have decimal places15.7
CharSingle character‘B’

Please note the use of quotation marks to indicate a string of text or single character.  String values without quotation marks will be mistaken for variables.

Also note the lack of quotation marks for the boolean value of TRUE.  This is because it is a logical state of being, not the storage of the string “TRUE”.

Topics / Programming / Data Types (in computer programs)

Popular Downloads