Module 1 · Meet C: Your First Programs, Symbol by Symbol
The Symbol Dictionary: Every Sign in C and What It Says
In this lesson
- Name every symbol C uses, with its proper name and one use.
- Recognise the four bracket kinds on sight and say which job each one does.
- Tell apart the six pairs that look alike, starting with a single quote and a double quote.
Bob points at his screen and asks Maria what the squiggly thing does. Maria asks which squiggly thing. There are three on that line.
Neither of them can look it up, because neither knows what it is called. This lesson is the dictionary. It turns "what does the little hat thing do" into "what does the caret operator do in C", which has an answer in one search.
Keep this lesson open while you work through the rest of the track. It is a reference page, not a chapter to memorise.
Brackets and braces: four pairs, four jobs
C uses four kinds of bracket, and they are not interchangeable. Using the wrong one is the fastest way to a confusing message.
| Symbol | Proper name | Also called | Use in C | First seen |
|---|---|---|---|---|
( ) | Parentheses | round brackets, parens | Function calls, parameter lists, conditions, grouping, casts | M1 lesson 1 |
{ } | Braces | curly brackets, curly braces | Blocks, function bodies, initialiser lists | M1 lesson 1 |
[ ] | Brackets | square brackets | Array declaration and indexing | M9 |
< > | Angle brackets | chevrons | System header includes, and as less-than and greater-than | M1 lesson 1 |
So parentheses call and group, braces hold blocks, brackets index arrays, and angle brackets do two unrelated jobs.
Arithmetic and assignment
| Symbol | Proper name | Also called | Meaning in C | First seen |
|---|---|---|---|---|
+ | Plus sign | plus | Addition, and unary plus | M1 lesson 2 |
- | Minus sign | hyphen, dash | Subtraction, and negation | M1 lesson 4 |
* | Asterisk | star, times | Multiplication; also declares and follows a pointer | M1 lesson 2 |
/ | Forward slash | slash, solidus | Division; also starts // and /* comments | M1 lesson 2 |
% | Percent sign | percent, mod | Remainder; also begins a printf placeholder | M4 |
= | Equals sign | equals, gets | Assignment, never comparison | M1 lesson 2 |
++ | Double plus | increment | Add one | M4 |
-- | Double minus | decrement | Subtract one | M4 |
+= | Plus equals | add and assign | x += 3 is x = x + 3 | M4 |
Read = out loud as "gets", not as "equals". That one habit prevents the trap from the last lesson.
Comparison and logic
| Symbol | Proper name | Also called | Meaning in C | First seen |
|---|---|---|---|---|
== | Double equals | equal to | Is equal to; gives 1 or 0 | M1 lesson 2 |
!= | Exclamation equals | not equal | Is not equal to | M1 lesson 3 |
< > | Less-than, greater-than | angle brackets | Comparison | M1 lesson 3 |
<= >= | Less-or-equal, greater-or-equal | Comparison | M1 lesson 3 | |
&& | Double ampersand | logical AND | True only when both sides are true | M5 |
|| | Double vertical bar | logical OR | True when either side is true | M5 |
! | Exclamation mark | bang, logical NOT | Turns true into false and back | M5 |
Every symbol in this table gives you a number: 1 for true, 0 for false. Example 2 below prints all six of the comparisons.
Punctuation and structure
| Symbol | Proper name | Also called | Use in C | First seen |
|---|---|---|---|---|
; | Semicolon | Ends a statement | M1 lesson 1 | |
, | Comma | Separates arguments, declarations and list items | M1 lesson 1 | |
. | Full stop | period, dot | Decimal point, and access to a member of a struct | M12 |
: | Colon | Labels, case, the second half of ? | M5 | |
? | Question mark | ternary | The conditional operator, paired with : | M5 |
' | Single quote | apostrophe | One character: 'A' | M1 lesson 4 |
" | Double quote | quotation mark | A string: "Hello" | M1 lesson 1 |
\ | Backslash | reverse slash | Starts an escape sequence such as \n | M1 lesson 1 |
# | Hash | number sign, pound | Preprocessor directives | M1 lesson 1 |
& | Ampersand | and sign | Address-of, and bitwise AND | M1 lesson 1 |
| | Vertical bar | pipe | Bitwise OR | M4 |
^ | Caret | hat, circumflex | Bitwise XOR | M4 |
~ | Tilde | squiggle | Bitwise NOT | M4 |
_ | Underscore | low line | Allowed inside names, and the usual word separator | M1 lesson 5 |
-> | Arrow | A struct member, reached through a pointer | M12 |
That is the whole punctuation set. Nothing else in C is a symbol you have not now met.
The six pairs that look alike
These are the pairs that cost beginners hours. Each row is two symbols that sit next to each other on the keyboard and mean unrelated things.
| Pair | The first one | The second one | How to keep them apart |
|---|---|---|---|
'A' and "A" | One character, 1 byte | A string, 2 bytes: the letter and the terminator | Single quote holds exactly one character |
= and == | Stores a value | Compares two values | Say "gets" for one, "is equal to" for the other |
& and && | Address-of, or bitwise AND | Logical AND | Two symbols means a yes-or-no question |
/ and \ | Division, and comment starts | Escape sequences | The one that leans forward divides |
* in two jobs | a * b multiplies | int *p declares a pointer | A type on the left means a pointer |
<stdio.h> and a < b | A header to include | A comparison | Only a #include line uses the first |
Exercise 2 below is a program that uses four of these six in a row, and asks you to predict what it prints.
Escape sequences: the characters with no shape
A backslash inside a string starts an escape sequence. It is how you type a character that has no visible shape of its own, or one that would otherwise end the string.
| Escape | Name | What it does |
|---|---|---|
\n | Newline | Move to the start of the next line |
\t | Horizontal tab | Jump to the next tab stop |
\\ | Backslash | Print one literal backslash |
\" | Double quote | Print a quote without ending the string |
\' | Single quote | Print a literal apostrophe |
\0 | Null character | Marks the end of a C string |
\r | Carriage return | Move to the start of the current line |
\a | Alert | Ring the terminal bell |
\b | Backspace | Move back one character |
%% | Percent, doubled | Not an escape: this is how printf prints one % |
Each escape is one character in the output, however many you typed. Counting that correctly is the brain teaser at the end.
One short program that uses every bracket C has, with a comment naming each job.
#include <stdio.h> /* angle brackets: a system header */
int main(void) /* parentheses: the parameter list */
{ /* braces: the body of main */
int marks[3] = {90, 85, 77}; /* brackets declare, braces initialise */
printf("%d\n", marks[0]); /* parentheses call, brackets index */
return 0;
}
90
Arrays are Module 9, so do not worry about marks[3] yet. Notice only that four different brackets appear, and that swapping any pair of them breaks the program.
Comparisons are not magic. Each one is an expression whose value is 1 or 0, and printf can print it like any other number.
#include <stdio.h>
int main(void)
{
int a = 7;
int b = 4;
printf("a == b gives %d\n", a == b);
printf("a != b gives %d\n", a != b);
printf("a > b gives %d\n", a > b);
printf("a < b gives %d\n", a < b);
printf("a >= b gives %d\n", a >= b);
printf("a <= b gives %d\n", a <= b);
return 0;
}
a == b gives 0
a != b gives 1
a > b gives 1
a < b gives 0
a >= b gives 1
a <= b gives 0
Change b to 7 and run it again. Four of the six answers flip, and the two that do not are the pair you should be able to name.
This is the program to keep. It prints a tab-separated table, a quoted phrase, a Windows path and a percentage, which covers every escape you will use this month.
#include <stdio.h>
int main(void)
{
printf("Name\tMarks\n");
printf("Zara\t92\n");
printf("Kenji\t87\n");
printf("She said \"well done\"\n");
printf("Path: C:\\progsity\\bin\n");
printf("Discount: 15%%\n");
return 0;
}
Name Marks
Zara 92
Kenji 87
She said "well done"
Path: C:\progsity\bin
Discount: 15%
Look at the last two lines in the source. Two backslashes print one, and two percent signs print one. Everywhere else, the first of the pair is the instruction.
Run in CompilerWhere this is used
- Reading a compiler message.
expected '=', ',', ';', 'asm' or '__attribute__' before '-' tokenis unreadable until you can say "before the minus sign". The message names symbols, so you have to name them too. - Asking for help. A forum or a search engine answers "what does the caret operator do in C" and cannot answer "what does the little hat thing do". Exact words are a debugging tool.
- Reading documentation. The C standard library pages describe
printfin terms of conversion specifications beginning with a percent sign. The names in this lesson are the names those pages use. - Code review at work. "You have an ampersand where you want a double ampersand" is a sentence a reviewer says out loud. It saves the reader from re-reading the line.
Common mistakes
1. A single-quoted string.
printf('Hello\n');
GCC 12 gives warning: multi-character character constant and then a warning about passing an integer where a pointer belongs. It builds, and usually crashes. Single quotes hold exactly one character; text needs double quotes.
2. A double-quoted single character.
char grade = "A";
On GCC 12 this is warning: initialization of 'char' from 'char *' makes integer from pointer without a cast, and an error on GCC 14. You stored an address in a one-byte box. What you wanted was 'A'.
3. One backslash where you meant a literal backslash.
printf("Path: C:\progsity\bin\n");
There is no message you can rely on here. \p is undefined behaviour that GCC quietly prints as p, and \b is a real escape, the backspace, which eats the character before it. The output looks almost right and is not. Double every literal backslash.
4. A hyphen in a name.
int total-marks = 90;
The message is error: expected '=', ',', ';', 'asm' or '__attribute__' before '-' token. C read the hyphen as subtraction and then found nothing to subtract from. Names use the underscore, which is why the next lesson calls it total_marks.
Zara was taking notes by hand and wrote the names of the symbols instead of the symbols. Put the real symbols back, so the program prints the expression and its value.
Input. One line with two integers a b.
Output. One line, exactly: (a + b) * 2 = X, with the two numbers and the answer filled in.
Constraints. 0 <= a, b <= 1000.
Sample. Input 7 4 gives (7 + 4) * 2 = 22. The parentheses and the asterisk are printed as characters, and the doubling is real arithmetic.
#include <stdio.h>
int main(void)
{
int a, b;
scanf("%d %d", &a, &b);
/* Print: open-paren, a, space, plus, space, b, close-paren,
space, asterisk, space, 2, space, equals, space, the value. */
printf("%d\n", 0);
return 0;
}
Graded against hidden tests in the module's Problems lesson, as restore-symbols.
Predict the four lines this program prints, on paper, before you run it. Then run it and check.
#include <stdio.h>
int main(void)
{
int a = 6;
int b = 3;
char grade = 'A';
printf("%d\n", a & b);
printf("%d\n", a && b);
printf("%c\n", grade);
printf("%d\n", a / b);
return 0;
}
What to notice. Lines 1 and 2 differ by one character and give different answers. Bitwise AND is Module 4, so for now you only need to see that the two symbols are not the same symbol.
Check yourself. Write down what each of the four lines is called before you look: bitwise AND, logical AND, a character, integer division. If you can name all four, this lesson has done its job.
Run in CompilerCommon doubts
Do I have to memorise all of these?
No. You need the four bracket names and the six look-alike pairs. The rest is a page to come back to, which is why the last column says where each symbol first appears.
Why does C use so much punctuation?
Because it was designed for a slow terminal in 1972, where a short symbol beat a long word. Python chose words for some of the same jobs, which is easier to read and more to type.
Are the "also called" names wrong?
They are informal, and everybody uses them. Say curly brackets if you like, and know that the standard and every error message call them braces.
Which symbols can I use in a name?
Letters, digits and the underscore, and a name may not start with a digit. Everything else in these tables is an operator or punctuation, so it ends the name.
What about the symbols I see in other people's code, like
<<?They are combinations of the ones here.
<<is two less-than signs and means a bit shift, from Module 4. If you can name the parts, you can look up the pair.
Key takeaways
- Four bracket kinds, four jobs: parentheses call, braces block, brackets index, angle brackets include or compare.
- Every symbol has a proper name, and error messages use it.
- Single quotes hold one character; double quotes hold a string.
&and&&,=and==,/and\are three pairs that look alike and mean unrelated things.- An escape sequence is one character in the output, however many you typed.
- Two backslashes print one, and two percent signs print one.
Next you will see why a character is really a small number, and the complete table that says which number each character is.
End of lesson 3
Mark it done, and your progress moves with you.
Next: The Complete ASCII Table, All 128 Rows