Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Programs, source code, and compilers

~25 min

Your phone's alarm, a web browser, and the game you played last week are all programs. So is everything you'll write in this course. Before you install anything, it helps to know what happens between typing some text and seeing a program do something. That gap is where Rust does most of its work for you.

Source code, compilers, and executables

A program is a set of steps a computer follows to get a job done. Your alarm app is a program. Its steps are roughly: wait until 7:00, then play a sound.

The chip inside a computer that follows the steps is called the processor. It is very fast and very literal. It only understands steps written as numbers, one tiny step at a time, like "add these two numbers" or "move this number over there". Steps written in that number form are called machine code. A phone's chip and a laptop's chip don't even speak the same number language.

People don't write numbers like that. They write words and symbols a person can read, using a coding language like Rust. That readable text is called source code. You type it into an ordinary text file. A Rust source file's name ends in .rs, the way a photo's name might end in .jpg.

So there's a language gap: you write readable text, and the chip reads only numbers. A compiler closes the gap. It is a translator program. It reads your whole text file, checks that you followed Rust's rules, and then writes a brand-new file of machine code. That new file is called an executable, because it's the file your computer can execute, which means run. Programmers also call it a binary. On Windows its name ends in .exe. On a Mac or on Linux, the name normally stops with no dot and letters after it.

Here's the part that surprises people. The text file and the executable are two different files. Think of a recipe card and the cake baked from it. Crossing out "sugar" on the card doesn't change the cake already on the table. You have to bake again. In the same way, if you change your source code, you have to run the compiler again to get a new executable.

A program is a list of instructions a computer carries out, in order, to do a job. The part of the computer that carries them out is the processor. A processor understands only one kind of instruction: machine code, small operations such as "add these two numbers" or "copy these bytes", each stored as a pattern of numbers. Different processor families (the chips in most laptops, the chips in most phones) use different machine code.

Nobody writes machine code by hand anymore. People write source code: the text of a program in a programming language such as Rust, typed into an ordinary text file. Rust source files end in .rs. Source code is written for people to read and change, so the processor can't use it directly. It has to be translated first.

A compiler is the program that does that translation. It reads the whole source file and checks that it follows the language's rules. Then it writes out an executable (also called a binary): a new file of machine code, plus a little bookkeeping the operating system needs to start it. On Windows an executable's name ends in .exe; on macOS and Linux it usually has no ending at all. The source file and the executable are separate files. Changing one does not change the other, so after you edit the source you must compile again to get a new executable.

Here is a complete Rust program, the traditional first one, with two extra lines. You'll type and run it yourself in Chapter 1. For now, read it.

fn main() {
    // A note for people. The compiler skips this line.
    println!("Hello, world!");
    println!("I am a Rust program.");
}
Hello, world!
I am a Rust program.

The box under the code shows what the program printed when this page was built. Line by line:

  • fn main() { marks where the program starts. Everything between this { and the matching } on the last line is the list of steps.
  • A line that starts with // is a comment: a note for human readers. The compiler ignores it, so it never prints.
  • println!("..."); prints the text between the double quotes, then moves to a new line. The quotes themselves aren't printed. The ! is part of the name; Chapter 1 explains why it's there. The ; ends the instruction, the way a full stop ends a sentence.
  • The steps run top to bottom, so Hello, world! comes out first.

From hello.rs to Hello, world!

Loading interactive…

Written by a person, or made by the compiler?

Sort each card: is it source code a person writes, or something the compiler produced from source code?

Loading interactive…

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

What this task checks

Structure checked automatically. Whether your ideas are convincing isn't graded, so reread with the checklist.

The compiler says

A model answer

Correct answer

Also accepted:

Why

Why

Files ending in .rs, and any line you can read as Rust, are source code. The .exe, the scrambled-looking file, and the file you start by double-clicking are executables: machine code the compiler wrote.

Worked example

Which file do you change?

  1. 1

    Priya compiled greet.rs yesterday. Her folder now holds two files: greet.rs and greet.exe. She wants the program to print Good evening instead of Good morning.

  2. 2

    greet.exe is machine code. Opened in a text editor it looks like scrambled symbols, and editing it by hand would only break it. The readable version of the program is greet.rs, so that's the file to change.

    the executable is output, not something you edit

  3. 3

    She changes the quoted text in greet.rs to Good evening and saves. Then she starts greet.exe again. It still prints Good morning.

  4. 4

    Nothing is broken. greet.exe was translated from yesterday's text, and it doesn't read greet.rs when it runs. She runs the compiler on greet.rs again, which writes a fresh greet.exe, and now the program prints Good evening.

Worked example

Reading a program before running it

  1. 1

    Here is a short program. Before looking at the output, decide what it prints.

    fn main() {
        println!("Step 1: boil water");
        // println!("Step 2: add salt");
        println!("Step 3: add pasta");
    }
    
    Step 1: boil water
    Step 3: add pasta
    
  2. 2

    Start at fn main() { and go down. The first println! prints Step 1: boil water.

  3. 3

    The next line starts with //, so the whole line is a comment, even though what follows looks like a real instruction. The compiler skips it, and Step 2 never prints.

    // switches off the rest of its line

  4. 4

    The last println! prints Step 3: add pasta. Two lines of output, in the order the instructions appear, with the numbering jumping from 1 to 3.

Check your understanding (counts toward your progress)

In the first line of a Rust program, fn main() {, what does main mark?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

Nothing prints from that line. It opens the list of steps rather than printing anything.

The executable's name comes from the file, as in hello.rs giving hello. main is where running begins.

Comments start with //. fn main() { is real code the compiler reads.

Why

fn main() { marks the start of the program. Every step between that { and its matching } runs, top to bottom, when you start the executable.

Look at what sits between the { on that line and the } at the bottom.

Why can't the processor run hello.rs as it is?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

A one-line .rs file is just as unreadable to a processor. Size isn't the issue.

Any text editor opens a .rs file. Opening isn't the problem; the processor understanding it is.

Running a finished program downloads nothing. The translation happens once, on the computer doing the compiling.

Why

A processor carries out small instructions stored as numbers, which is machine code. Rust is text written for people, so a compiler translates it before anything runs.

What form do a processor's instructions take?

Sort each item: did a person write it, or did the compiler produce it?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

What this task checks

Structure checked automatically. Whether your ideas are convincing isn't graded, so reread with the checklist.

The compiler says

A model answer

Why

.rs files and readable Rust lines are source code. The .exe, the scrambled-looking file, and anything described as machine code came out of the compiler.

Correct answer

Also accepted:

Why

Source code is text you can read like instructions. Machine code isn't.

Lena changes Hello to Hi there in greet.rs and saves. She starts the greet.exe she compiled yesterday, and it still prints Hello. Why?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

Saving is instant. The executable never reads greet.rs at all, so no amount of waiting updates it.

Executables aren't stuck forever. Compiling again writes a fresh one from the new source.

Spaces inside quotes print fine. The real problem is the missing recompile.

Why

An executable is a snapshot of the source at the moment it was compiled. Change the source, compile again, and only then does the program change.

Does the executable read greet.rs each time it starts?

Practice: Source code, compilers, and executables (5 problems · doesn’t affect your progress)

Which of these is written by a person for other people to read?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

Machine code is numbers for a processor. People don't write it anymore.

An executable is machine code the compiler wrote.

Those symbols are machine code shown as if it were text. Nobody wrote them to be read.

Why

Source code is the readable text a person types. The compiler turns it into machine code, stored in an executable.

Source code

One line of output. What is it?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

What this task checks

Structure checked automatically. Whether your ideas are convincing isn't graded, so reread with the checklist.

The compiler says

A model answer

Why

One println!, one line: the quoted text without its quotes.

Correct answer

Also accepted:

Why

Good morning

A packing list. Type what it prints.

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

What this task checks

Structure checked automatically. Whether your ideas are convincing isn't graded, so reread with the checklist.

The compiler says

A model answer

Why

The // line is a comment, so Umbrella never prints. The other three print top to bottom.

Correct answer

Also accepted:

Why

One line is only a note for people.

Tent ⏎ Stove ⏎ Map

You edit menu.rs and start the old menu.exe without compiling. What prints?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

The executable doesn't read menu.rs, so it can't know about your edit.

It has no idea the source exists. It just runs.

It runs normally. It's just yesterday's version.

Why

The executable is a snapshot from the last compile. Compile again to pick up the edit.

The old text, from before your edit

Ana's program prints Done twice, but she only wants it once. Her folder holds tasks.rs and tasks. What should she do?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

tasks is the executable, machine code that looks scrambled in an editor. Changing it by hand breaks it.

Running it again just prints Done twice again.

Renaming changes nothing inside the file or the executable.

Why

Change the source, then compile again so a new executable replaces the old one.

Delete one println!("Done"); line in tasks.rs, then compile again

Compiled ahead of time, or interpreted as it runs

Think about getting a speech across a language barrier. One way is to have the whole speech translated in advance, printed, and handed out. The other is to bring a person who stands beside the speaker and turns each sentence into the listeners' language out loud, as it's spoken.

Coding languages come in the same two styles. A compiled language works like the printed copy. Rust is one. The compiler translates your entire program first. Later, as a separate step, you run the result. Because that work is finished, you can give the executable to a friend. It runs on their computer, as long as it has the same kind of chip and the same system, such as Windows. They don't need the compiler. They never see your source code either.

An interpreted language works like the person at the speaker's side. A helper program, called an interpreter, reads your source code and carries it out bit by bit while it runs. Nothing is prepared in advance. So the helper must be installed on each computer where the program is used. And if there's a mistake near the end of the file, nobody finds out until the program reaches that spot. Python, as most people run it, works this way.

The real world is messier than two neat boxes. Many interpreters prepare a little ahead of time, behind the scenes. What matters for this course is when your program gets checked. With Rust, every line is checked before the program exists at all.

There are two broad ways to get from source code to a running program. A compiled language, such as Rust, translates the whole program ahead of time. Compiling is one step and running is a separate, later step, and the executable runs on its own: the person running it needs no compiler and no copy of the source. An interpreted language hands the source code to a helper program called an interpreter, which reads it and carries it out piece by piece while it runs. Nothing is translated ahead of time, so every computer that runs the program needs the interpreter installed, and a mistake late in the file may go unnoticed until that line is reached. Real systems blur the line (many interpreters do some translation internally), but the difference that matters here is when the checking happens: for Rust, all of it happens before the program exists.

Translated in advance, or as it runs?

Sort each statement: does it describe a compiled language like Rust, or an interpreted one?

Loading interactive…

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

What this task checks

Structure checked automatically. Whether your ideas are convincing isn't graded, so reread with the checklist.

The compiler says

A model answer

Correct answer

Also accepted:

Why

Why

A compiler finishes all its translating and checking first, so the result stands alone and a mistake anywhere stops it being made. An interpreter works while the program runs, so it must be present every time, and a late mistake surfaces only when the program gets there.

Worked example

Sharing a finished program

  1. 1

    Jonas wrote a small quiz game in Rust and compiled it on his Windows laptop into quiz.exe. His sister also runs Windows and has never installed anything for programming.

  2. 2

    Rust is compiled, so quiz.exe already holds the machine code. He can send her that one file. She double-clicks it and the game runs. She never needs his quiz.rs.

  3. 3

    If the game were written in an interpreted language, he'd have to send the source file instead. She'd also need the interpreter installed before it could run.

  4. 4

    One limit: quiz.exe is machine code for Windows on that kind of chip. It won't start on a Mac. For that, he'd compile the same quiz.rs again for the Mac.

    same source, a new translation per kind of computer

Check your understanding (counts toward your progress)

Marco's friend now tries game.exe on a Mac, and it won't start. What's the fix?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

Renaming doesn't change what's inside. It would still be Windows machine code, just with a misleading name.

Rust programs aren't interpreted. The Mac needs its own executable.

Resaving machine code in a text editor at best changes nothing and at worst breaks it.

Why

Machine code is specific to the kind of computer. The same source compiles again into an executable for the Mac.

Is machine code the same for every kind of computer?

The same broken line 9 sits in a program written for an interpreter. What's the likely result when someone runs it?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

That's the compiled behavior. An interpreter works as it goes, so it hasn't looked at line 9 yet when line 1 runs.

Interpreters don't write executables. They carry out the source directly.

The line still breaks the rules. The interpreter complains when it gets there.

Why

An interpreter carries out the source as it reads it, so the early lines run and the mistake surfaces only when that line comes up.

An interpreter translates as it goes, like a live interpreter at a speech.

Rust is a compiled language. What does that mean?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

That's how an interpreter works. Rust does all its translating first, as a separate step.

Compiled Rust programs run straight on the computer, no browser involved.

The whole point of the executable is that it stands alone. The source stays with the person who wrote it.

Why

A compiled language is translated ahead of time into an executable. Running it is a separate, later step, and the source isn't needed then.

Think of the printed translation of a speech, handed out in advance.

Practice: Compiled or interpreted (4 problems · doesn’t affect your progress)

Which picture fits a compiled language like Rust?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

That's the interpreted style: translation while the program runs.

Some translation is always needed. The processor reads only machine code.

Nothing is played backwards. The question is when the translating happens.

Why

Compiling finishes the whole translation before the program runs, like a printed translation handed out in advance.

A speech translated and printed in advance

Which needs to be installed on every computer that runs the program: the Rust compiler, or a language's interpreter?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

A compiled Rust program runs from its executable alone.

Only the interpreted program needs its helper present.

An interpreted program can't run without its interpreter.

Why

An interpreted program is carried out by its interpreter each time it runs. A compiled program's executable stands on its own.

The interpreter, for an interpreted program

Rust finds a broken rule on the last line. How much of the program runs?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

That's what an interpreter might do. Rust checks everything before anything runs.

The broken line can't run, and neither can any other.

Skipping lines isn't something the compiler does.

Why

Rust checks the whole program first. A broken rule anywhere means no executable, so nothing runs.

None; no executable is made

You compiled clock.rs on a Windows laptop. A friend with a Linux laptop wants the program. What's the honest answer?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

Machine code is made for one kind of computer and operating system.

A .rs file is text. Double-clicking opens it in an editor at best.

The name isn't the problem; the machine code inside is for Windows.

Why

Executables are specific to the kind of computer. The same source compiles into a new executable for Linux.

Compile clock.rs again for Linux; the Windows executable won't start there

When the compiler refuses to build it

Before the compiler writes anything, it reads your whole program and checks it against Rust's rules. Think of a building inspector who checks the plans before any construction starts. If one rule is broken, the compiler stops and prints an error: a message saying which file, which line, and what it expected to see. And it makes no executable. So there's nothing to run, not even the lines above the mistake. That's what people mean when they say "the compiler refused to build it."

Look at the program just below this explanation. Its error message is real, copied from the compiler when this page was built. Line 2 is missing the ; at its end. Without it, the compiler has no way to know where one instruction stops and the next one begins. Its message says three things. First, the complaint: it expected a ; but found the word println. Second, the place: src/main.rs:2:35 means the file src/main.rs, line 2, character 35 along. (Rust projects keep their main file under that name, which you'll see in Chapter 1.) Third, the line itself, with a ^ pointing at the spot and a hint: add ; here.

A refusal feels like a setback, but it's the compiler doing you a favor. Fixing a mistake now takes you a minute. Found later, by someone using your program, the same mistake means a crash, lost work, or worse. Rust's compiler is famously strict. Later chapters show it catching whole families of serious bugs before the program ever runs, bugs other languages only find by crashing.

Before it writes an executable, the compiler checks the whole program against the language's rules. If any rule is broken, it prints an error, which names the file, the line and column, and what it expected, and it writes no executable at all. "The compiler refuses to build it" means this: there is no program to run, not even the lines before the mistake. In the program below the pair of explanations, line 2 lacks its closing ;, so the compiler can't tell where the first instruction ends. Its message reads top to bottom: the complaint, then the location (src/main.rs:2:35 is file, line 2, column 35), then the offending line with a ^ under the exact spot and a suggested fix. The refusal is a feature. A mistake the compiler catches costs a minute at your desk; the same mistake found while the program is running costs a crash in front of whoever is using it. Rust's compiler is unusually strict, and later chapters show it rejecting whole kinds of bugs, such as using memory after it has been handed back, that other languages only discover at run time.

Here is that program and the compiler's complete reply.

fn main() {
    println!("Starting the count")
    println!("Done");
}
error: expected `;`, found `println`
 --> src/main.rs:2:35
  |
2 |     println!("Starting the count")
  |                                   ^ help: add `;` here
3 |     println!("Done");
  |     ------- unexpected token

Bug hunt: find the line that stops the build

This program has 1 mistake that makes the compiler refuse to build it. Click the broken line.

Loading interactive…

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

What this task checks

Structure checked automatically. Whether your ideas are convincing isn't graded, so reread with the checklist.

The compiler says

A model answer

Correct answer

Also accepted:

Why

Why

Line 3 has no ; after its closing bracket, so the compiler can't tell where that instruction ends and the next println! begins. Adding ; at the end of line 3 fixes it.

Worked example

Fixing a program the compiler refused

  1. 1

    Sam compiles this program and gets an error instead of an executable.

    fn main() {
        println!("Welcome back");
        println!("You have 3 new messages);
    }
    
    error[E0765]: unterminated double quote string
     --> src/main.rs:3:14
      |
    3 |       println!("You have 3 new messages);
      |  ______________^
    4 | | }
      | |_^
    
  2. 2

    Read the first line of the message: an unterminated double quote string. Unterminated means "never ended". Some text in quotes was opened and never closed.

  3. 3

    The location says line 3, column 14, which is where the opening " sits. The drawing underneath runs from there to the end of the file: the compiler kept reading, looking for the closing quote, and never found one.

    the error points where the trouble starts, not always where the fix goes

  4. 4

    Put the missing " after messages, so the line reads println!("You have 3 new messages");, and compile again. This time there's no error, an executable appears, and it prints both lines.

Where this goes next

Chapter 1 §3 has you type the hello-world program above into a real .rs file. You run the compiler on it yourself and start the executable it makes. Chapter 2 §1 looks inside the compiler. It follows your source text all the way down to machine code for your computer. Chapter 2 §4 is a full lesson on reading compiler errors like the two on this page. It covers the message, the location, the pointer, and the hint.

Check your understanding (counts toward your progress)

The compiler refuses this program. Click the 1 line that causes it.

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

What this task checks

Structure checked automatically. Whether your ideas are convincing isn't graded, so reread with the checklist.

The compiler says

A model answer

Why

Line 3 opens a quote before Latte and never closes it, so the compiler reads on looking for the end of the text. A " after ready fixes it.

Correct answer

Also accepted:

Why

Count the double quotes on each line. They come in pairs.

In an error message, what does a ^ under part of a line show?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

It's a pointer, not a character to add. The hint next to it says what to add.

Nothing ran. Error messages come from compiling, before any running.

Printed text has no bold. The ^ is just an arrow under the problem.

Why

The compiler copies the offending line and puts ^ under the precise spot, often with a short hint beside it.

An error message includes src/main.rs:2:35. What does that tell you?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

The numbers after the file name are a location, not a count.

Nothing ran. The compiler found this before any executable existed.

It's a place to look, not an instruction. And 35 is how far along line 2 the problem sits.

Why

The compiler gives the file, the line number, and the column (how many characters along), so you can go straight to the spot.

It reads file, then line, then column.

Practice: When the compiler refuses (5 problems · doesn’t affect your progress)

What does a compiler error message usually give you?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

Nothing ran. Errors come from checking, before running.

There's no executable when there's an error.

Rust's messages say a lot more: where, what, and often how to fix it.

Why

An error names the complaint, points at the file, line, and column, shows the line with a ^, and often suggests a fix.

The problem, the file, the line and column, and often a hint

1 line stops this program from building. Click it.

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

What this task checks

Structure checked automatically. Whether your ideas are convincing isn't graded, so reread with the checklist.

The compiler says

A model answer

Why

Line 2 has no ; at its end, so the compiler can't tell where it stops.

Correct answer

Also accepted:

Why

1 mistakes fixed

This one won't build either. Click the 1 broken line.

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

What this task checks

Structure checked automatically. Whether your ideas are convincing isn't graded, so reread with the checklist.

The compiler says

A model answer

Why

Line 3 opens a quote before Team and never closes it. The compiler reads on to the end of the file looking for it.

Correct answer

Also accepted:

Why

Pair up the double quotes on each line.

1 mistakes fixed

Order the lines so the program builds and prints Knock knock, then Who's there?. One line is a decoy.

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

What this task checks

Structure checked automatically. Whether your ideas are convincing isn't graded, so reread with the checklist.

The compiler says

A model answer

Why

fn main() { opens, the two println! lines follow in printing order, and } closes. The decoy never closes its quote.

Correct answer

Also accepted:

Why

One Knock knock line has only one double quote.

E → D → C → B

This program has 2 mistakes. Click both lines.

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

What this task checks

Structure checked automatically. Whether your ideas are convincing isn't graded, so reread with the checklist.

The compiler says

A model answer

Why

Line 2 has no ;, and line 4 never closes the quote after Green. The compiler needs both fixed.

Correct answer

Also accepted:

Why

One line lacks its ending; another lacks a partner quote.

2 mistakes fixed

Feeling good about this section?

Take the section quiz

Every answer gets a full explanation at the end.

Sign in to save highlights

Insert an equation

  • No matches.