Table of Contents

    Common Data Types

    Programming Mastery

    Common Data Types

    Learn the most common data types used in programming, including numbers, text, booleans, characters, dates, lists, arrays, objects, and null values, with simple examples and practical use cases.

    What are Common Data Types?

    Common data types are the basic categories of data that programmers use frequently while writing programs. They help the computer understand what kind of value is being stored, processed, compared, or displayed.

    Different programming languages may use different names for data types, but the core idea is usually similar. Most programs work with numbers, text, true/false values, dates, lists, and structured data.

    Common data types are the standard kinds of values used in most programs.

    For example, a student management program may use text for student names, numbers for marks, boolean values for pass/fail status, and lists for storing multiple subject marks.

    Easy Real-Life Example

    Data Types as Different Boxes

    Imagine you are organizing your room. You may use one box for books, another box for clothes, another for documents, and another for small tools. Each box stores a different kind of item.

    Similarly, in programming, different data types store different kinds of values. Numbers, text, true/false values, and lists are handled differently because they serve different purposes.

    Most Common Data Types

    The following are common data types that beginners should understand first.

    Common Data Type List

    • Integer
    • Decimal / Floating-point
    • String / Text
    • Character
    • Boolean
    • Date and Time
    • List / Array
    • Object / Record
    • Null / Empty value

    Common Data Types Summary Table

    Data Type Used For Example Values
    Integer Whole numbers 10, 0, -25
    Decimal / Float Numbers with decimal points 3.14, 99.50, -0.75
    String / Text Words, sentences, symbols, or text data "Ravi", "Hello", "A101"
    Character A single character or symbol 'A', '9', '#'
    Boolean True or false values true, false
    Date and Time Date, time, or timestamp values 2026-07-01, 10:30 AM
    List / Array Multiple values stored together [80, 75, 85]
    Object / Record Grouped related data {name, age, marks}
    Null / Empty Missing or no value null, none, empty

    1. Integer Data Type

    An integer data type is used to store whole numbers. Whole numbers do not have decimal points.

    Integers can be positive, negative, or zero.

    SET age = 18
    SET totalStudents = 45
    SET temperature = -5
    SET score = 0

    Common Uses of Integer

    • Age
    • Roll number
    • Quantity
    • Marks
    • Counter values
    • Number of students
    • Number of products

    2. Decimal / Floating-Point Data Type

    A decimal or floating-point data type is used to store numbers with decimal parts.

    Decimal values are useful when whole numbers are not enough.

    SET price = 99.50
    SET averageMarks = 82.75
    SET temperature = 32.5
    SET height = 5.8

    Common Uses of Decimal / Float

    • Product price
    • Average marks
    • Height and weight
    • Temperature
    • Percentage
    • Distance
    • Scientific calculations
    Beginner Tip: Use integer for whole numbers and decimal/float for values that may contain decimal points.

    3. String / Text Data Type

    A string or text data type is used to store characters, words, sentences, or symbols.

    Text values are usually written inside quotation marks in many programming languages.

    SET studentName = "Ravi"
    SET courseName = "Programming Mastery"
    SET email = "student@example.com"
    SET message = "Welcome to the course"

    Common Uses of String / Text

    • Names
    • Email addresses
    • Phone numbers when not used for calculation
    • Messages
    • Passwords
    • Addresses
    • Product titles
    • Course names

    Important Note

    A value like "100" is text if it is written inside quotes. It may look like a number, but the computer may treat it as a string.

    SET numberValue = 100
    SET textValue = "100"

    Here, numberValue is suitable for calculations, but textValue may need conversion before calculation.

    4. Character Data Type

    A character data type is used to store a single character, such as a letter, digit, or symbol.

    Some programming languages treat characters separately, while others treat them as short text values.

    SET grade = 'A'
    SET answer = 'Y'
    SET symbol = '#'

    Common Uses of Character

    • Grade letters
    • Single-letter answers
    • Symbols
    • Single initials
    • Menu options

    5. Boolean Data Type

    A boolean data type stores only two possible values: true or false.

    Boolean values are very useful in conditions, decision-making, validation, and status checking.

    SET isPassed = true
    SET isLoggedIn = false
    SET hasDiscount = true
    SET isActive = true

    Boolean Example in Decision-Making

    IF isLoggedIn THEN
        DISPLAY "Show dashboard"
    ELSE
        DISPLAY "Show login page"
    END IF

    Common Uses of Boolean

    • Login status
    • Pass/fail status
    • Active/inactive status
    • Yes/no decisions
    • Feature enabled/disabled
    • Validation result
    • Condition checking

    6. Date and Time Data Type

    Date and time data types are used to store dates, times, durations, or timestamps.

    These values are useful when a program needs to track events, deadlines, schedules, or history.

    SET birthDate = "2008-05-12"
    SET orderDate = "2026-07-01"
    SET loginTime = "10:30 AM"
    SET examDate = "2026-08-15"

    Common Uses of Date and Time

    • Date of birth
    • Order date
    • Exam date
    • Login time
    • Appointment time
    • Created date
    • Updated date
    • Deadline

    7. List / Array Data Type

    A list or array is used to store multiple values together.

    Lists are useful when we need to store many related items under one name.

    SET marksList = [80, 75, 85]
    SET studentNames = ["Ravi", "Priya", "Ankit"]
    SET prices = [100, 250, 75]

    Processing List Values

    FOR EACH mark IN marksList
        DISPLAY mark
    END FOR

    Common Uses of List / Array

    • List of marks
    • List of names
    • List of products
    • List of prices
    • List of tasks
    • List of orders
    • List of messages

    8. Object / Record Data Type

    An object or record is used to store related data as one unit.

    For example, one student may have a name, age, marks, result status, and course name. Instead of storing these separately, we can group them as one student record.

    SET student = {
        name: "Ravi",
        age: 18,
        marks: 80,
        isPassed: true
    }

    Common Uses of Object / Record

    • Student record
    • Employee record
    • Product details
    • Customer profile
    • Order information
    • Course details
    • Bank account information

    9. Null / Empty Value

    A null or empty value represents missing, unknown, or unavailable data.

    It is used when a variable exists, but it does not currently have a meaningful value.

    SET middleName = null
    SET selectedCourse = null
    SET discountCode = null

    Why Null Must Be Handled Carefully

    If a program expects a real value but receives null, it may behave incorrectly or show an error. Beginners should always check whether a value is available before using it.

    IF discountCode IS NOT null THEN
        APPLY discountCode
    ELSE
        DISPLAY "No discount code applied"
    END IF

    Primitive, Composite, and Special Data Types

    Common data types can be grouped into broad categories. This makes them easier to understand.

    Category Meaning Examples
    Primitive Data Types Basic single-value data types. Integer, decimal, string, boolean, character
    Composite Data Types Data types that store multiple or grouped values. List, array, object, record, map
    Special Data Types Data types that represent special states or meanings. Null, empty, undefined

    Choosing the Right Data Type

    Choosing the right data type is important because it affects how the program stores data, processes values, prevents errors, and produces output.

    Need Recommended Data Type Reason
    Store student age Integer Age is usually a whole number.
    Store product price Decimal / Float Price may contain decimal values.
    Store student name String / Text Name is text data.
    Store login status Boolean Status is true or false.
    Store multiple marks List / Array Multiple related values are needed.
    Store full student details Object / Record Related values can be grouped together.

    Complete Example: Common Data Types in One Program

    The following language-neutral example shows many common data types used together.

    /*
    This program stores student details and displays result information.
    */
    
    ENTRY POINT
        SET studentName = "Ravi"
        SET age = 18
        SET averageMarks = 82.5
        SET grade = 'A'
        SET isPassed = true
        SET subjects = ["Math", "Science", "English"]
        SET examDate = "2026-08-15"
    
        SET studentRecord = {
            name: studentName,
            age: age,
            average: averageMarks,
            grade: grade,
            passed: isPassed,
            subjects: subjects,
            examDate: examDate
        }
    
        DISPLAY studentRecord
    END ENTRY POINT

    Data Type Breakdown

    Variable Value Data Type
    studentName "Ravi" String / Text
    age 18 Integer
    averageMarks 82.5 Decimal / Float
    grade 'A' Character
    isPassed true Boolean
    subjects ["Math", "Science", "English"] List / Array
    examDate "2026-08-15" Date / Text representation
    studentRecord Grouped student details Object / Record

    How Common Data Types Help Debugging

    Understanding common data types helps students find errors faster. Many beginner mistakes happen because a value is stored in the wrong type.

    Debugging Questions

    • Is this value a number, text, or boolean?
    • Is a number accidentally stored as text?
    • Is the program trying to calculate with text?
    • Is the boolean value used correctly in a condition?
    • Is the list storing the expected values?
    • Is any value null or missing?
    • Is the object or record storing all required fields?
    • Does the chosen data type match the problem requirement?

    Best Practices for Common Data Types

    Students should follow these practices when choosing and using data types.

    Recommended Practices

    • Use integers for whole numbers.
    • Use decimal values for prices, averages, and measurements.
    • Use strings for names, messages, and descriptions.
    • Use booleans for true/false decisions.
    • Use lists or arrays for multiple related values.
    • Use objects or records for grouped related information.
    • Handle null or empty values carefully.
    • Use meaningful variable names that match the data type.
    • Convert values when the program receives data in the wrong type.
    • Test programs with different kinds of input values.

    Common Beginner Mistakes

    Mistakes

    • Confusing numbers with text values.
    • Using text data in mathematical calculations.
    • Using decimal values when only whole numbers are needed.
    • Using unclear names like x or data for important values.
    • Ignoring boolean values in conditions.
    • Using separate variables when a list would be better.
    • Using many unrelated variables instead of an object or record.
    • Not checking for null or missing values.

    Better Habits

    • Identify the type of value before storing it.
    • Choose a data type based on how the value will be used.
    • Use meaningful variable names.
    • Keep related data grouped properly.
    • Use collections for repeated or multiple values.
    • Use booleans clearly for yes/no decisions.
    • Convert input values when needed.
    • Test the program with valid, invalid, and missing data.

    Prerequisites Before Learning Common Data Types

    To understand common data types properly, students should know a few basic programming concepts.

    Basic Prerequisites

    • What is data?
    • What is a data type?
    • Why data types are needed.
    • Variables and identifiers.
    • Statements and expressions.
    • Input, process, and output model.
    • Basic arithmetic operations.
    • Basic conditions and true/false logic.

    Practice Activity: Identify Common Data Types

    This activity helps students identify data types from values.

    Task

    Identify the most suitable data type for each value.
    Value Most Suitable Data Type
    25 Integer
    99.99 Decimal / Float
    "Programming Mastery" String / Text
    'A' Character
    true Boolean
    [10, 20, 30] List / Array
    {name: "Ravi", age: 18} Object / Record
    null Null / Empty value

    Mini Quiz

    1

    Which data type is used for whole numbers?

    Integer is used for whole numbers.

    2

    Which data type is used for text?

    String or text data type is used for words, sentences, names, and messages.

    3

    Which data type is used for true or false values?

    Boolean data type is used for true or false values.

    4

    Which data type is suitable for multiple marks?

    A list or array is suitable for storing multiple marks.

    5

    What does null mean?

    Null means missing, empty, unknown, or unavailable value.

    Interview Questions on Common Data Types

    1

    Name some common data types used in programming.

    Common data types include integer, decimal, string, character, boolean, date/time, list, array, object, and null.

    2

    What is the difference between integer and decimal data?

    Integer data stores whole numbers, while decimal data stores numbers with fractional parts.

    3

    What is the difference between string and character?

    A string stores a sequence of characters, while a character stores a single character in languages that support character as a separate type.

    4

    What is the difference between primitive and composite data types?

    Primitive data types usually store simple single values, while composite data types store multiple or grouped values.

    5

    Why should we choose the correct data type?

    Choosing the correct data type helps the program store, process, validate, and display data correctly.

    Quick Summary

    Data Type Quick Meaning
    Integer Whole number.
    Decimal / Float Number with decimal part.
    String / Text Text, words, names, or messages.
    Character Single character or symbol.
    Boolean True or false value.
    Date and Time Date, time, or timestamp.
    List / Array Multiple values stored together.
    Object / Record Grouped related data.
    Null / Empty Missing or unavailable value.

    Final Takeaway

    Common data types are essential for writing correct and meaningful programs. They help programmers store numbers, text, true/false values, dates, lists, and structured records properly. In the Programming Mastery Course, students should learn not only the names of data types, but also when to use each one and why choosing the correct data type matters.