1.Which type of error prevents a program from running?
Easy
ASyntax error
BLogic error
CRuntime error
DOff-by-one error
2.Which type of error causes a program to crash while it is running?
Easy
ASyntax error
BLogic error
CRuntime error
DCompilation error
3.A program runs but produces an incorrect result. What type of error is most likely present?
Easy
ASyntax error
BLogic error
CRuntime error
DInput error
4.Which of the following is an example of a syntax error?
Easy
AUsing a variable before it is assigned
BDividing by zero
CMissing a colon at the end of a function definition
DAn array index going out of bounds
5.In the following pseudocode, what type of error is present?
FOR i ← 1 TO 10
OUTPUT i
NEXT i
(Assume the loop should output numbers 1 to 10, but it outputs 1 to 11.)
Medium
ASyntax error
BLogic error
CRuntime error
DNo error
6.Which of the following is NOT a common type of error in programming?
Easy
ASyntax error
BLogic error
CRuntime error
DDesign error
7.A programmer writes: IF age > 18 THEN OUTPUT 'Adult' ELSE OUTPUT 'Child'. The program always outputs 'Child' even when age is 20. What type of error is this?
Medium
ASyntax error
BLogic error
CRuntime error
DTypo error
8.A program crashes when the user enters a string instead of a number. This is an example of a:
Easy
ASyntax error
BLogic error
CRuntime error
DCompilation error
더 많은 문제
9.Which of the following is an example of a runtime error?
Easy
AMisspelling a variable name
BUsing = instead of == in a condition
CDividing by zero
DForgetting to declare a variable
10.A trace table is used to help identify which type of error?
Medium
ASyntax errors
BLogic errors
CRuntime errors
DAll of the above
11.Consider the code: x = 5; y = 0; result = x / y. This code will cause a:
Easy
ASyntax error
BLogic error
CRuntime error
DCompilation error
12.Which of the following best describes a logic error?
Easy
AThe program crashes when running
BThe program does not run at all
CThe program runs but produces wrong output
DThe program runs too slowly
13.A program is designed to calculate the average of three test scores. The code is:
sum = score1 + score2 + score3
average = sum / 3
If the user enters 10, 20, and 30, the program outputs 20.0 as expected. However, if the user enters 0, 0, and 0, the program outputs 0.0. What type of error, if any, is present in this code?
Medium
ANo error; the program works correctly for all inputs.
BSyntax error because division by zero is not allowed.
CLogic error because the average of zeros should be undefined.
DRuntime error because the program crashes when all scores are zero.
14.A program contains the line: IF score ≥ 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail". A student enters a score of 50 and the program outputs "Fail". What type of error is this?
Medium
ASyntax error
BLogic error
CRuntime error
DNo error
15.A program uses an array of size 10 (index 0 to 9). The following loop is intended to output all elements:
FOR i = 0 TO 10
OUTPUT array[i]
NEXT i
What type of error does this cause?
Medium
ASyntax error
BLogic error – outputs an extra element beyond the array bounds
CRuntime error – index out of bounds when i = 10
DNo error
16.Which of the following best describes a syntax error?
Easy
AAn error that causes the program to produce incorrect output
BAn error that breaks the grammatical rules of the programming language and prevents the program from running
CAn error that occurs during program execution, such as division by zero
DAn error that occurs when the program runs out of memory
17.A programmer writes the following pseudocode to find the largest of three numbers:
IF num1 > num2 THEN
IF num1 > num3 THEN
OUTPUT num1
ELSE
OUTPUT num3
ELSE
IF num2 > num3 THEN
OUTPUT num2
ELSE
OUTPUT num3
If num1 = 5, num2 = 5, num3 = 3, what is the output?
Medium
A5
B3
C5 (but it should output 5, so no error)
DThe program crashes
18.A program calculates the average of a list of numbers. The code is:
sum = 0
FOR i = 1 TO LENGTH(list)
sum = sum + list[i]
NEXT i
average = sum / LENGTH(list)
Assuming the list contains 5 numbers, what type of error is present if the list is indexed starting from 0?
Medium
ASyntax error
BLogic error – the average will be incorrect because the first element is skipped
CRuntime error – index out of bounds when i = LENGTH(list)
DNo error
19.A program reads a number from the user and then computes 10 / number. If the user enters 0, what type of error occurs?
Easy
ASyntax error
BLogic error
CRuntime error
DNo error
20.Which of the following is an example of a logic error?
Medium
AUsing a variable before it has been assigned a value
BMissing a closing bracket
CDividing by zero
DTyping 'pritn' instead of 'print'
21.A program uses a while loop that never ends because the condition never becomes false. What type of error is this?
Medium
ASyntax error
BLogic error
CRuntime error
DNo error
22.A programmer writes the following pseudocode to count down from 5 to 1:
FOR i = 5 TO 1
OUTPUT i
NEXT i
What type of error does this contain?
Medium
ASyntax error – the FOR loop syntax is incorrect
BLogic error – the loop will not execute because the start value is greater than the end value
CRuntime error – the program crashes when i becomes less than 1
DNo error
23.A program contains the line: x = 5 y = 10 (without any operator between them). What type of error is this?
Easy
ALogic error
BRuntime error
CSyntax error
DNo error
24.A program is supposed to output the sum of numbers from 1 to 10. The code is:
sum = 0
FOR i = 1 TO 10
sum = sum + i
NEXT i
OUTPUT sum
The output is 55, which is correct. However, the programmer notices that if the loop is changed to 'FOR i = 0 TO 10', the output becomes 55 as well. Why is there no error in the original code?
Medium
AThe original code has a logic error, but it accidentally gives the correct answer.
BThe original code is correct; starting from 1 to 10 sums the numbers 1 through 10 inclusive, giving 55.
CThe original code has a syntax error because the loop variable should start at 0.
DThe original code has a runtime error because i is not declared.
25.A program is designed to calculate the average of a list of numbers. The code is:
sum = 0
FOR i = 1 TO LENGTH(list)
sum = sum + list[i]
NEXT i
average = sum / LENGTH(list)
The program runs but the average is always too high. What type of error is most likely present?
Medium
ALogic error
BSyntax error
CRuntime error
DOff-by-one error
26.A program uses an array of size 10 (index 0 to 9). The following loop is intended to output all elements:
FOR i = 0 TO 10
OUTPUT array[i]
NEXT i
What type of error occurs?
Medium
ARuntime error
BSyntax error
CLogic error
DOff-by-one error
27.A program calculates the average of three test scores. The code is:
sum = score1 + score2 + score3
average = sum / 3
If the user enters 10, 20, and 30, the output is 20.0, which is correct. However, if the user enters 10, 20, and 'abc', the program crashes. What type of error is this?
Medium
ARuntime error
BSyntax error
CLogic error
DInput error
28.A programmer writes the following pseudocode to find the largest of three numbers:
IF num1 > num2 THEN
IF num1 > num3 THEN
OUTPUT num1
ELSE
OUTPUT num3
ENDIF
ELSE
IF num2 > num3 THEN
OUTPUT num2
ELSE
OUTPUT num3
ENDIF
ENDIF
If the numbers are 5, 5, and 3, what is the output?
Medium
A5
B3
CNo output
DError
29.What is a logic error?
Easy
AAn error that causes the program to crash.
BAn error that prevents the program from running.
CAn error that causes the program to run but produce incorrect output.
DAn error that occurs when dividing by zero.
30.A programmer writes the following pseudocode to calculate the average of three numbers:
sum = num1 + num2 + num3
average = sum / 3
OUTPUT average
If the user enters 10, 20, and 30, the output is 20.0, which is correct. However, if the user enters 0, 0, and 0, the output is 0.0. What type of error, if any, is present?
Easy
ASyntax error
BLogic error
CRuntime error
DNo error
31.Which of the following is a common example of a logic error?
Medium
AMissing a closing bracket.
BUsing a variable before it is assigned a value.
CTrying to open a file that does not exist.
DSpelling a keyword incorrectly.
32.A program uses an array of size 10 (index 0 to 9). The following loop is intended to output all elements:
FOR i = 0 TO 10
OUTPUT array[i]
NEXT i
What type of error does this contain?
Medium
ASyntax error
BLogic error
CRuntime error
DBoth logic and runtime error
33.Which of the following best describes the use of a trace table?
Easy
ATo translate high-level code into machine code.
BTo help identify logic errors by manually tracking variable values.
CTo automatically fix syntax errors in the code.
DTo measure the execution time of a program.
34.What type of error causes a program to crash while it is running?
Easy
ASyntax error
BLogic error
CRuntime error
DDesign error
35.A program is designed to calculate the area of a rectangle. The code includes:
if length < 0 or width < 0:
raise ValueError("Length and width must be positive values.")
area = length×width
If the user enters length = 10 and width = 0, the program outputs 0.0 instead of an error message. What type of error is present?
Medium
ASyntax error
BLogic error
CRuntime error
DNo error
36.A programmer writes the following pseudocode to calculate the average of a list of numbers:
sum = 0
FOR i = 1 TO LENGTH(list)
sum = sum + list[i]
NEXT i
average = sum / LENGTH(list)
If the list contains the numbers [10, 20, 30], what will be the output?
Medium
A20
B30
C10
D60
37.A program contains the following code:
x = 5
WHILE x > 0
OUTPUT x
x = x - 1
ENDWHILE
What type of error is present?
Easy
ASyntax error
BLogic error
CRuntime error
DNo error
38.A program is designed to find the largest number in a list. The code is:
largest = 0
FOR i = 1 TO LENGTH(list)
IF list[i] > largest THEN
largest = list[i]
ENDIF
NEXT i
OUTPUT largest
If the list contains [-5, -2, -10], what will be the output?
Medium
A0
B-2
C-5
D-10
39.A programmer writes the following pseudocode to output the numbers 1 to 5:
FOR i = 1 TO 5
OUTPUT i
NEXT i
The program outputs 1, 2, 3, 4, 5. What type of error is present?
Easy
ASyntax error
BLogic error
CRuntime error
DNo error
40.A program uses the following code to count the number of even numbers in a list:
count = 0
FOR i = 1 TO LENGTH(list)
IF list[i] MOD 2 = 0 THEN
count = count + 1
ENDIF
NEXT i
OUTPUT count
If the list is [1, 3, 5, 7], what is the output?
Medium
A0
B1
C4
DError
41.Which type of error prevents a program from running at all?
Easy
ASyntax error
BLogic error
CRuntime error
DArithmetic error
42.A logic error causes the program to crash immediately.
Easy
True or false?
43.Using a variable before it has been assigned a value is an example of a runtime error.
Medium
True or false?
44.Arrange the following steps in the correct order to identify and fix a logic error:
Medium
Run the program with test data
Use a trace table to track variable values
Compare actual output with expected output
Correct the faulty code
45.Match each error type to its correct description:
Medium
Syntax error
Logic error
Runtime error
Produces incorrect output
Causes the program to crash
Prevents the program from running
46.Which of the following are examples of logic errors? (Select all that apply)
Medium
AUsing ≤ instead of < in a loop condition
BMisspelling a variable name
CForgetting to initialise a counter variable
DDividing by zero
EUsing OR instead of AND in a condition
47.Match each error type to its correct description.
Medium
Syntax error
Logic error
Runtime error
Breaks grammatical rules and prevents the program from running
Causes the program to crash during execution
Produces incorrect output but the program runs
48.Arrange the following steps in the correct order to identify and fix a logic error using a trace table.
Medium
Run the algorithm with test data and record variable values
Compare expected output with actual output
Identify the step where the value differs from expected
Correct the code and re-test
49.A program is written to calculate the average of a list of numbers. The pseudocode is:
sum = 0
FOR i = 1 TO LENGTH(list)
sum = sum + list[i]
NEXT i
average = sum / LENGTH(list)
OUTPUT average
The program outputs an average of 5.5 for the list [1, 2, 3, 4, 5, 6]. The expected average is 3.5. What type of error is present?
Medium
ASyntax error
BLogic error
CRuntime error
DNo error
50.Which of the following are examples of runtime errors? (Select all that apply)
Medium
ADividing by zero
BMissing semicolon at end of a statement
CAccessing an array element with an index out of range
DUsing the wrong variable name in a calculation
ETrying to open a file that does not exist
51.Complete the sentence.
Easy
A ____ error breaks the grammatical rules of a programming language and stops the program from running.
52.State one example of a syntax error.
Easy
53.A programmer writes code to calculate the average of three numbers: sum = num1 + num2 + num3; average = sum / 3. If the user enters 10, 20, and 30, what is the actual output? (Enter the number only)
Medium
54.A program is designed to calculate the area of a rectangle. The pseudocode is:
INPUT length
INPUT width
IF length < 0 OR width < 0 THEN
OUTPUT "Error: positive values required"
ELSE
area = length×width
OUTPUT area
ENDIF
A test with length = 5 and width = 0 produces an area of 0. What is the output for test data length = 0 and width = 5?
Medium
55.State one example of a syntax error in the following pseudocode:
FOR i = 1 TO 10
OUTPUT i
NEXT i
Medium
56.Describe the difference between a logic error and a runtime error.
Medium
57.Describe the difference between a logic error and a runtime error. Give one example of each.
Hard
58.A programmer writes code to calculate the average of three numbers: sum = num1 + num2 + num3; average = sum / 3. If the user enters 10, 20, and 30, what is the actual output? (Enter the number only)
Medium
A18
B22
C24
D20
59.A program is designed to calculate the area of a rectangle. The pseudocode is:
INPUT length
INPUT width
IF length < 0 OR width < 0 THEN
OUTPUT "Error: positive values required"
ELSE
area = length×width
OUTPUT area
ENDIF
A test with length = 5 and width = 0 produces an area of 0. What is the output for test data length = 0 and width = 5?
Medium
A2
B3
C0
D1
Unlock all 59 questions & more
무료 계정을 만들어 이 주제의 모든 문제, 슬라이드, 플래시카드, 복습 노트를 확인하세요.