Comments
Notes in your code that the computer ignores.
2 minute read
Big idea
A comment is a note for humans. The computer skips it completely.
The idea
Comments explain why your code does something — for someone reading it later (often future you). They never change what the program does.
C has two kinds:
//— a comment until the end of the line./* ... */— a comment that can cover many lines.
Example
#include <stdio.h>
int main(void) {
// This line says hello
printf("Hello\n");
/* This whole block
is ignored too */
return 0;
}output
HelloRun and edit it in the app.
Only Hello is printed. Both comments are skipped.
Watch it
Think of it like
Sticky notes on a recipe. The cook reads them, but they aren't cooking steps.
🕷️ Spidey-sense: Comments are the sticky notes I leave on my web-shooters for future me. The computer skips them completely — they're only for humans. Write why you did something, not just what.
Common mistake
Forgetting to close a block comment. Everything after /* stays a comment until */ — even your real code.
Key terms
- Comment — A note in code that the compiler ignores.
- // — Starts a single-line comment.
- /* */ — Wraps a multi-line comment.
Check yourself
What does the computer do with a comment?
Which is a single-line comment?
Which comment can cover many lines?