Essential Programming Concepts: Variables, Data Types, and Algorithms
Classified in Computers
Written on in
English with a size of 1.89 KB
Variables and Constants
Variable
A named data location in a program for a value that can be changed throughout the execution of the program.
- Definition: A storage location containing data that can be modified.
- Usage: Once created and assigned, a variable can be used repeatedly and reassigned new values.
- Naming: Use descriptive names related to the stored data. Avoid spaces to prevent syntax errors.
Constant
A named data location in a program for a value that remains the same throughout the program's execution.
- Definition: A storage location for values that should not change.
- Benefit: Updating the value at the definition point automatically updates it everywhere the constant is used.
Data Types
- String: A sequence of characters or symbols.
- Numbers:
- Integer: A whole number without decimal points (e.g., 100).
- Real (Float): Numbers that include decimals or fractions.
- Character: A data type that holds exactly one character (e.g., 'M' or 'F').
- Boolean: A logical type that holds only two values, such as TRUE/FALSE or YES/NO.
Algorithms and Logic
Algorithm
A set of instructions designed to solve a specific problem.
Sequence
A series of instructions that must be executed in the correct order to solve a problem.
Example Sequence
- Input the first number.
- Store the first number.
- Input the second number.
- Add the first number to the second number.
- Output the result.
- Stop the program.
Executed
Refers to a program that is currently being run by the computer.