ICAS Programming and Digital Systems Questions and Answers — Questions and Answers
Question 1: In a computer program, a special container is used to store a value that can be changed later. For example, it could hold a player's score, which starts at 0 and increases. What is this container called?
- A function
- A constant
- A variable (Correct answer)
- An operator
Correct answer: A variable
A variable is a named storage location in a program that holds a value which can be changed during the program's execution. A constant holds a value that does not change, a function is a block of code that performs a task, and an operator is a symbol like '+' or '-' that performs an operation.
Question 2: Computers process and store all information using a base-2 number system. What is the name of this system and which two digits does it use?
- Decimal, using 0-9
- Hexadecimal, using 0-F
- Octal, using 0-7
- Binary, using 0 and 1 (Correct answer)
Correct answer: Binary, using 0 and 1
The binary number system is the fundamental language of computers. It is a base-2 system that uses only two digits, 0 and 1, to represent all data.
Question 3: Consider the following sequence of instructions: 1. SET a TO 5 2. SET b TO 10 3. SET a TO a + b 4. SET b TO a - b After all instructions are executed, what is the final value of 'b'?
- 15
- 5 (Correct answer)
- 10
- 0
Correct answer: 5
1. 'a' is 5. 2. 'b' is 10. 3. 'a' becomes its current value (5) plus 'b' (10), so 'a' is now 15. 4. 'b' becomes the new value of 'a' (15) minus the old value of 'b' (10), so 'b' is now 5.
Question 4: A programmer wants to write a set of instructions that repeats a specific action exactly 50 times. Which of the following programming structures is the most appropriate for this task?
- An IF-ELSE statement
- A variable declaration
- A FOR loop (Correct answer)
- A comment
Correct answer: A FOR loop
A FOR loop is a control structure used for definite iteration, meaning it repeats a block of code a known number of times. An IF-ELSE statement is for making decisions, not for repetition.
Question 5: In digital electronics, a specific logic gate will only output a 1 (TRUE) if BOTH of its inputs are 1 (TRUE). If either input is 0 (FALSE), the output is 0 (FALSE). Which gate is this?
- OR gate
- NOT gate
- AND gate (Correct answer)
- XOR gate
Correct answer: AND gate
An AND gate performs a logical 'and' operation. Its output is true only when all of its inputs are true. An OR gate is true if at least one input is true, and a NOT gate inverts its single input.
Question 6: A user is asked to enter their age into a program. The program then follows this logic: IF age < 18 THEN DISPLAY "Child ticket" ELSE DISPLAY "Adult ticket" END IF If the user enters the age 18, what will the program display?
- Child ticket
- Both "Child ticket" and "Adult ticket"
- The program will show an error
- Adult ticket (Correct answer)
Correct answer: Adult ticket
The condition checks if the age is LESS THAN 18. Since 18 is not less than 18, the condition is false. Therefore, the program executes the code in the ELSE block and displays "Adult ticket".
In a computer program, a special container is used to store a value that can be changed later.
For example, it could hold a player's score, which starts at 0 and increases.
What is this container called?