A2 Chapter 13. Data Representation Flashcards
1
Q
What is a variable in programming?
A
- A named location in memory used to store data.
- The value of a variable can change during program execution.
2
Q
What is a constant in programming?
A
- A named location in memory with a value that cannot be changed during program execution.
- Used to store fixed values.
3
Q
What are data types in programming?
A
- Categories of data that define the operations that can be performed on the data and the way the data is stored.
- Examples: Integer, Float, String, Boolean.
4
Q
What is an array in programming?
A
- A collection of elements of the same data type, stored in contiguous memory locations.
- Accessed using an index.
5
Q
What is a function in programming?
A
- A block of code designed to perform a specific task.
- Can be reused multiple times in a program.
6
Q
What is the difference between a procedure and a function?
A
- Procedure: A block of code that performs a task but does not return a value.
- Function: A block of code that performs a task and returns a value.
7
Q
What is recursion in programming?
A
- A technique where a function calls itself to solve smaller instances of the same problem.
- Used in problems like factorial calculation, Fibonacci sequence.
8
Q
What are control structures in programming?
A
- Constructs that control the flow of execution in a program.
- Types: Sequence, Selection (if-else), Iteration (loops).
9
Q
What is a loop in programming?
A
- A control structure that repeats a block of code as long as a specified condition is true.
- Examples: For loop, While loop.
10
Q
What is the purpose of an if-else statement?
A
- A control structure used to execute different blocks of code based on a condition.
- Allows decision-making in a program.
11
Q
What is a switch/case statement?
A
- A control structure that allows a variable to be tested for equality against a list of values.
- Executes the block of code corresponding to the matching case.
12
Q
What is the difference between a for loop and a while loop?
A
- For loop: Executes a block of code a specific number of times.
- While loop: Executes a block of code as long as a condition is true.
13
Q
What is a nested loop?
A
- A loop inside another loop.
- The inner loop is executed completely for each iteration of the outer loop.
14
Q
What is an exception in programming?
A
- An error that occurs during the execution of a program.
- Can be handled using try-catch blocks to prevent program crashes.
15
Q
What is the purpose of debugging?
A
- The process of finding and fixing errors or bugs in a program.
- Ensures the program runs correctly and efficiently.