Conditional statements, or if-statements, are programming constructs that change a program's sequential flow of control by executing different blocks of code based on whether a Boolean expression evaluates to true or false (EK AAP-2.H.1), implementing selection in AP CSP.
A conditional statement is how a program makes a decision. Without conditionals, code runs top to bottom in order, every line, every time. A conditional interrupts that flow. It checks a Boolean expression (something that is either true or false) and uses the answer to decide which code actually runs. The CED calls this idea selection, which means determining which parts of an algorithm get executed based on a condition being true or false (EK AAP-2.G.1).
On the AP CSP exam reference sheet, you get two forms. The basic form is IF (condition) { <block of statements> }, where the block runs only if the condition is true, and nothing happens if it is false (EK AAP-2.H.2). The second form adds an ELSE, IF (condition) { <first block> } ELSE { <second block> }, which guarantees exactly one of the two blocks runs, the first when the condition is true and the second when it is false (EK AAP-2.H.3). Think of it like a fork in the road. The Boolean expression is the road sign, and the conditional is the fork itself.
Conditional statements live in Topic 3.6 (Conditionals) in Unit 3: Algorithms and Programming, the heaviest-weighted unit on the AP CSP exam. Two learning objectives are built around them. 3.6.A asks you to express an algorithm that uses selection without using a programming language, so you need the concept, not just the syntax. 3.6.B asks you to both write conditional statements and determine their results, which is exactly what code-tracing MCQs test. Selection is also one of the three building blocks of every algorithm, alongside sequencing and iteration, so conditionals show up far beyond Topic 3.6. They appear inside loops, inside procedures, and in your Create performance task program, which must include selection.
Keep studying AP Computer Science Principles Unit 3
Boolean Expression (Unit 3)
Every conditional is powered by a Boolean expression. The expression produces the true/false value, and the conditional acts on it. If you can't evaluate Boolean expressions with relational operators (like a > b) and logical operators (AND, OR, NOT), you can't predict what a conditional will do.
If Statements (Unit 3)
The if-statement is the basic form of a conditional on the exam reference sheet. The key behavior to remember is that when the condition is false, the block is simply skipped and the program moves on. Nothing runs, but the program doesn't stop or error.
Else Statements (Unit 3)
Adding ELSE turns one possible path into two guaranteed paths. With IF-ELSE, exactly one of the two blocks always executes. That's the detail MCQs love to test, because students often assume the else block can also be skipped.
Conditionals show up in multiple-choice questions in two main ways. First, conceptual stems ask what a conditional does, like "How does a conditional statement affect program flow?" or "In an algorithm, what does a conditional statement do?" The answer always comes back to selection, meaning the program executes different statements based on a Boolean expression. Second, code-tracing questions give you pseudocode with IF or IF-ELSE blocks and ask you to determine the result, which is the skill in 3.6.B. Watch for questions about the else block specifically, since the exam tests whether you know exactly one branch of an IF-ELSE runs. There is no traditional FRQ on AP CSP, but your Create performance task program must include an algorithm with selection, so you will write and explain a conditional in your own code.
A Boolean expression and a conditional statement are not the same thing, even though they always appear together. The Boolean expression is the question, something like score >= 70, and it evaluates to true or false. The conditional statement is the decision structure that uses that answer to choose which code runs. On the exam, evaluating the expression wrong (especially with AND, OR, and NOT) is the most common reason students trace a conditional incorrectly.
Conditional statements, also called if-statements, change the sequential flow of control by executing different statements based on the value of a Boolean expression.
Selection means determining which parts of an algorithm run based on a condition being true or false, and conditionals are how selection is written in code.
With a plain IF statement, the block runs when the condition is true and nothing happens when it is false.
With IF-ELSE, exactly one of the two blocks always executes, the first block when the condition is true and the else block when it is false.
You need to do two things with conditionals on the exam, write them correctly using the reference sheet format and trace given code to determine the result.
Selection is one of the three core algorithm building blocks along with sequencing and iteration, and your Create task program must include it.
A conditional statement (if-statement) is a construct that executes different blocks of code based on whether a Boolean expression is true or false. It implements selection, which is one of the three building blocks of algorithms in Topic 3.6 of the CED.
Nothing runs from that block. Per the exam reference sheet (EK AAP-2.H.2), the block of statements inside IF (condition) { } only executes when the condition is true, and no action is taken when it is false. The program just continues to the next line after the block.
No, it runs only when the condition is false. The key fact is that in an IF-ELSE, exactly one of the two blocks executes every time, never both and never neither. This is a favorite multiple-choice trap.
The Boolean expression is the true/false test, like x > 10. The conditional statement is the IF or IF-ELSE structure that uses that result to decide which code to run. The expression answers a question; the conditional acts on the answer.
Basically yes. Selection is the concept (deciding which parts of an algorithm execute based on a condition, EK AAP-2.G.1), and conditional statements are how you write selection in code. LO 3.6.A even asks you to express selection without a programming language, so know the idea, not just the syntax.