C Workshop · Comments
Lesson C

Comments

Comments are for humans. The compiler ignores them.

What it is

A comment is a note to a human. The compiler skips it completely, so it never changes what the program prints. You write comments so the next reader — including future you — knows why a line exists.

Approach

  1. Write a short comment above the printf that states the intent.
  2. Keep the actual statement that prints the message.
  3. Compile and run — output must still be exactly the required text.

Where this is used in the real world

Diagram

1

Comment

ignored by gcc

Humans read it; the CPU never does.
2

printf

this is the real work

Only statements produce output.
3

Output

Kodin C

Same result with or without the comment.

Run algorithm

Each step highlights the matching C line. Program output appears only when a line that prints actually runs.

Ready
C code
1#include <stdio.h>
2int main(void) {
3  /* This program greets the learner */
4  printf("Kodin C\n");
5  return 0;
6}
What this line does
Press Run algorithm. The highlight will move through the C code.
Program output
(no output yet)

Check your understanding

Five questions. Pick one answer each, then Check answers. The correct choice turns green.

1. Does a comment change the program output?

Comments are for humans.

2. Which comment can wrap several lines?

Block comments span lines.

3. What still runs in this lesson?

Only the statement prints.

4. Why write a comment here?

Intent, not speed.

5. If you comment out printf, output is:

No statement means no output.