Programming
Computer systems do not have any consciousness, they simple follow sets of instructions to carry out specific tasks and operations. Programming is used to "tell" the computers to do those tasks.
Data Types
In programs, data needs to be stored appropriately so that it can easily be accessed and manipulated. Data types are like categories that tell the computer which type of data you are using. This is important as it will allow the computer to know what kind of operations can be done on the data.
Sometimes, a single piece of data may be representable by multiple data types. If that happens, the programmer must choose a data type which is best suited for the problem or the most memory-efficient.
Few Data Types:
Integer: Whole number (positive, negative, or zero).
Real/Float: Number with fractional parts.
Boolean: True or false value.
Character: A single letter, number, or symbol.
String: A collection of characters.
Date/Time: Stores a point in time, in various formats.
Pointer/Reference: Stores memory addresses.
Records: Collection of fields with different data types.
Arrays: Indexed collection of elements, all of the same type.
Generally, there are two categories of data types: primitive and composite.
Primitive data types are basic building blocks of data in a programming language. They are single units of data within a language. E.g. Integers, Booleans and Floats.
Composite data types are made up of multiple primitive data types, they simply connect multiple pieces of data together. E.g. Arrays and Records.
User-defined data types
User-defined data types are custom data types which programmers can create to help them meet their specific needs. Unlike built-in data types (like integers or strings), you define the structure and components of these types.
Here are a few common examples:
Structures (Structs): You can bundle different types of data together into one type. For example, you could create a "Person" data type that includes:
Name (String)
Age (Integer)
Gender (Character)
Classes (in Object-Oriented Programming): A blueprint for creating objects. A class can have attributes (like a struct) and behaviours (functions or methods) associated with it. For example, a "Car" class might have:
Attributes: colour, model, speed
Methods: accelerate, brake
Enums (Enumerations): A type that defines a set of named values. For instance, you could define an "enum" for the days of the week, where "Monday", "Tuesday", etc., are the values.
Last updated