In AP Computer Science Principles, a syntax error is a mistake in a program where the rules of the programming language are not followed (EK CRD-2.I.2), like a missing parenthesis or misspelled keyword, which usually stops the program from running at all.
A syntax error happens when your code breaks the grammar rules of the programming language. Think of it like writing a sentence with no period or spelling a word so badly your reader can't decode it. The computer literally cannot understand what you wrote, so it refuses to run the program. The CED defines it directly in EK CRD-2.I.2 as "a mistake in the program where the rules of the programming language are not followed."
Classic examples include a missing closing parenthesis or bracket, a misspelled keyword (like writing REPAET instead of REPEAT), or forgetting required punctuation. The good news is that syntax errors are usually the easiest of the four AP CSP error types to find, because the computer flags them before the program even runs. Compare that to a logic error, where the program runs fine but gives you the wrong answer.
Syntax errors live in Topic 1.4, Identifying and Correcting Errors, in Unit 1 (Creative Development). Learning objective AP Comp Sci P 1.4.A asks you to do two things with any error: identify it and correct it. To do that, you have to know all four error types the CED names. A syntax error (broken language rules), a logic error (program runs but behaves incorrectly, EK CRD-2.I.1), a run-time error (mistake that occurs during execution, EK CRD-2.I.3), and an overflow error (a number outside the defined range, EK CRD-2.I.4). The exam loves giving you a buggy code snippet and asking which category the bug falls into, so being able to classify errors quickly is a real point-earner. Syntax errors also connect to testing under 1.4.B, since testing with defined inputs only helps you once the code actually runs, which means syntax errors get fixed first.
Keep studying AP® Computer Science Principles Unit 1
Logic error (Unit 1)
The classic exam contrast. A syntax error stops the program from running, while a logic error lets it run but produces the wrong result. Dividing three test scores by 2 instead of 3 is perfectly valid code, so it's a logic error, not a syntax error.
Run-time error (Unit 1)
A run-time error happens while the program is executing, like dividing by zero. The timing is the giveaway. Syntax errors are caught before the code runs; run-time errors crash it mid-execution.
Testing with defined inputs (Unit 1, Topic 1.4)
EK CRD-2.J.1 says testing uses defined inputs to check for expected outcomes. But testing can't even start until syntax errors are fixed, because the program won't run. Syntax errors are the first wall you hit in debugging; logic errors are what testing is actually designed to catch.
Syntax errors show up almost exclusively in multiple-choice classification questions. A typical stem describes a bug, like code that divides by the wrong number, or shows a snippet with a missing bracket, and asks "What type of error is this?" Your job is to sort it into one of the four CED categories. Watch for the trap question phrased as "Which of the following would NOT be a syntax error?" where the wrong answers are all broken-grammar mistakes and the correct answer is a logic or run-time error hiding in valid code. The quick test you should run in your head is simple. Would this code even run? If no, it's syntax. If it runs but gives wrong output, it's logic. If it crashes during execution, it's run-time. There is no FRQ section on the current AP CSP exam, so this term is purely an MCQ skill.
A syntax error breaks the language's rules, so the program won't run at all. A logic error follows all the rules perfectly but does the wrong thing, so the program runs and gives incorrect or unexpected output. Misspelling REPEAT is syntax. Dividing by 2 when you meant 3 is logic. If the code runs, it's not a syntax error.
A syntax error is a mistake where the rules of the programming language are not followed, straight from EK CRD-2.I.2.
Syntax errors prevent the program from running, which makes them different from logic errors, where the code runs but behaves incorrectly.
Common examples are missing parentheses or brackets, misspelled keywords, and missing required punctuation.
AP CSP defines four error types in Topic 1.4: syntax, logic, run-time, and overflow, and the exam expects you to tell them apart.
Use the quick test on MCQs: won't run means syntax, runs wrong means logic, crashes mid-execution means run-time, number out of range means overflow.
Syntax errors get fixed before testing even matters, because testing with defined inputs (1.4.B) requires a program that actually runs.
It's a mistake in a program where the rules of the programming language are not followed, as defined in EK CRD-2.I.2 of the CED. Examples include a missing parenthesis or a misspelled keyword, and it usually prevents the program from running.
No, that's a logic error. Code that adds three test scores correctly but divides by 2 instead of 3 follows all the language rules, so it runs fine and just produces the wrong answer. That's the exact distinction AP CSP MCQs test.
A syntax error is caught before the program runs because the code breaks the language's rules. A run-time error happens during execution, like dividing by zero, and each programming language defines its own run-time errors (EK CRD-2.I.3).
Ask whether the program would run at all. Missing brackets, unmatched parentheses, and misspelled keywords are syntax errors. If the described code runs but gives wrong output, classify it as a logic error instead.
Yes. Syntax errors are part of Topic 1.4 (Identifying and Correcting Errors) under learning objective AP Comp Sci P 1.4.A, and they show up in multiple-choice questions asking you to classify a described bug as syntax, logic, run-time, or overflow.
Connect this key term to the AP exam workflow: review the course, practice questions, and check related study tools.
Review units, study guides, and course resources.
Check this vocabulary in multiple-choice context.
Apply key concepts in written AP responses.
Estimate the exam score you are working toward.
Review the highest-yield facts before practice.
Put the full course together before test day.