ICAS Digital Systems and Programming 2 — Questions and Answers
Question 1: Which data type would you use to store the value 3.14 in most programming languages?
- integer
- float (Correct answer)
- boolean
- string
Correct answer: float
A float (floating-point) data type stores decimal numbers like 3.14.
Question 2: What does a 'while' loop do in programming?
- Runs code a fixed number of times
- Repeats code as long as a condition is true (Correct answer)
- Defines a function
- Stores a value in memory
Correct answer: Repeats code as long as a condition is true
A while loop repeatedly executes its block of code as long as the specified condition remains true.
Question 3: In binary, what is the value of 1101?
- 11
- 13 (Correct answer)
- 15
- 12
Correct answer: 13
1101 in binary equals 8+4+0+1 = 13 in decimal.
Question 4: What is the purpose of an 'if-else' statement?
- To repeat code multiple times
- To store multiple values
- To make decisions based on a condition (Correct answer)
- To define a new variable
Correct answer: To make decisions based on a condition
An if-else statement executes one block of code if a condition is true, and another block if it is false.
Question 5: Which of the following best describes a computer network?
- A single computer with many programs
- Two or more computers connected to share resources (Correct answer)
- A program that manages files on one computer
- A type of input device
Correct answer: Two or more computers connected to share resources
A network is two or more connected computers that can communicate and share resources like files and printers.
Question 6: What does 'debugging' mean in programming?
- Writing new code
- Finding and fixing errors in a program (Correct answer)
- Compiling code into machine language
- Saving a file
Correct answer: Finding and fixing errors in a program
Debugging is the process of identifying and correcting errors or 'bugs' in a program.
Question 7: What does the NOT logic gate do to an input signal?
- Combines two inputs into one output
- Outputs the same value as the input
- Inverts the input signal (Correct answer)
- Adds two binary numbers
Correct answer: Inverts the input signal
A NOT gate outputs the opposite of its input: if the input is 1, the output is 0, and vice versa.
Which data type would you use to store the value 3.14 in most programming languages?