Program Editor (INPUT)

Ctrl + Enter to run

Console (Output)

Ready

📖 APCSP Syntax Reference

Assignment, Display, and Input

a ← expression
DISPLAY(expression)
INPUT()

Arithmetic Operators

a + b    a - b    a * b    a / b
a MOD b

Relational and Boolean Operators

a = b    a ≠ b    a > b    a < b    a ≥ b    a ≤ b
NOT condition
condition1 AND condition2
condition1 OR condition2

Selection

IF(condition)
{
   <block of statements>
}

IF(condition)
{
   <first block of statements>
}
ELSE
{
   <second block of statements>
}

Iteration

REPEAT n TIMES
{
   <block of statements>
}

REPEAT UNTIL(condition)
{
   <block of statements>
}

List Operations

aList ← [value1, value2, value3]
aList[i]          # 1-indexed!
x ← aList[i]
aList[i] ← x
INSERT(aList, i, value)
APPEND(aList, value)
REMOVE(aList, i)
LENGTH(aList)

FOR EACH item IN aList
{
   <block of statements>
}

String Operations

CONTAINS(text, substring)    # Returns true/false
text[i]                      # 1-indexed character access
SUBSTRING(text, start, end)  # 1-indexed, inclusive
LENGTH(text)

Example:
text ← "HELLO WORLD"
DISPLAY(text[1])                    # "H"
DISPLAY(SUBSTRING(text, 1, 5))      # "HELLO"
IF(CONTAINS(text, "WORLD"))
{
   DISPLAY("Found it!")
}

Procedures

PROCEDURE procName(parameter1, parameter2, ...)
{
   <block of statements>
   RETURN(expression)
}

Built-in Functions

RANDOM(a, b)
LENGTH(aList or text)
CONTAINS(text, substring)
SUBSTRING(text, start, end)

APCSP Blocks View

ARIA
ARIA
Pseudocode Helper