LearnBrainfuck basics

Numbers are letters

By the end of this lesson you can print any character, and you know why the character 7 is not the number 7.

Every character has a number

Below are all 95 characters you can see on a keyboard, each key with its number under it. Press a few, then find the capital letter H and read its number:

Print

This program is 72 plus signs and one full stop. Press Play, or drag the slider all the way to the right, and watch the line Printed:

The next letter

The box holds the program of the last figure, which prints H. Add to it, so that it prints HI. The line under the figure says what it prints now:

A digit is a character too

This program prints the character 0, with 48 plus signs. Change it so that it prints the character 7, and count how many plus signs it takes:

Check yourself

A free exercise

Print the first letter of your own name. Look up its number in the chart of step 1. Nothing is checked here:

What you can do now

You can look up the number of a character and print it with ., and you can add 48 to turn a number from 0 to 9 into its digit. These are the commands you know, and the numbers worth remembering:

The commands of Lessons 1 to 3.
CommandWhat it does
+ −Add 1 to the cell under the pointer, or take 1 off.
> <Move the pointer one cell to the right or to the left.
.Print the cell as one character.
The numbers worth remembering.
CharactersNumbers
line break10
space32
the digits 0 to 948 to 57
the capitals A to Z65 to 90
the small letters a to z97 to 122

A small letter is always 32 more than its capital. The full table, with the control characters, is in the Reference.

Seventy-two plus signs for one letter is a lot of typing. Lesson 4 shows how to repeat.