First jBC programs
Learn jBC by running short programs and changing the inputs. Use the Run
button to open a program in the playground. You can also save a program
as example.b and run uvx jbcc --run example.b
with uv and a C compiler installed.
Print a greeting
CRT prints to the terminal and adds a newline. Text in single quotes is a string literal.
CRT 'Hello from jBC!'
Expected output is Hello from jBC!. Change the greeting and run it again.
Calculate a total
Variables need no type declaration. Assign a value with = before
reading it. Arithmetic can use a numeric string such as '3'.
The : operator joins text and values for display.
quantity = '3' unit_price = 12 total = quantity * unit_price CRT 'Total: ' : total
Expected output is Total: 36. See Numeric variables and String variables.
Make a decision
IF chooses a branch based on a condition. Here GE
means greater than or equal to. Try changing the score to 59.
score = 72 IF score GE 60 THEN CRT 'Pass' END ELSE CRT 'Try again' END
Expected output is Pass.
Choose between several cases
BEGIN CASE checks each CASE in order and runs the first one that
matches. CASE 1 is always true, so place it last as the fallback.
status_code = 'S' BEGIN CASE CASE status_code EQ 'P' CRT 'Pending' CASE status_code EQ 'S' CRT 'Shipped' CASE 1 CRT 'Unknown status' END CASE
Expected output is Shipped.