Unit 1 SDD - Implementation - Data Types & Structures Flashcards
Why is it important to define data types in a program?
Data types tell the program what kind of data a variable will hold, ensuring correct storage and operations in RAM.
What are the main data types in programming?
Integer, Real, Character, String, and Boolean.
What does the INTEGER data type store? Give an example.
Stores whole numbers (positive or negative). Example: 17.
What does the REAL data type store? Give an example.
Stores numbers with decimal places (floating-point numbers). Example: 17.65.
What does the CHARACTER data type store? Give an example.
Stores a single letter, number, or symbol. Example: ‘$’.
What does the STRING data type store? Give an example.
Stores text or alphanumeric combinations (a group of characters). Example: ‘Bitesize’.
Why shouldn’t numbers used for calculations be stored as a STRING?
Because string data is treated as text and cannot be used directly in calculations. Instead, they should be stored as INTEGER or REAL.
What does the BOOLEAN data type store? Give an example.
Stores True or False values. Sometimes represented as 1 (true) and 0 (false).
What are the two types of data structures required for National 5?
Variables and 1D arrays.
Why are data structures important in programming?
They store user inputs and results from internal processes, making it possible to manage and manipulate data efficiently.
How does program analysis relate to data structures?
Almost every input or process identified in a program’s functional requirements needs a data structure to store data.
What is a data structure?
A data structure is a way of storing multiple values or items together in an organized manner.
Why is STRING considered both a data type and a data structure?
A STRING is an array of characters stored together in sequence, making it both a data type and a structured way of storing text.
How is the name ‘Anne’ stored as a STRING?
It is stored as an array of four characters: ‘A’, ‘n’, ‘n’, ‘e’.
What is an array?
An array is a data structure that allows multiple values to be stored in a list format under a single variable.