0
0
Rustprogramming~5 mins

Writing first Rust program - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the entry point of a Rust program?
The entry point of a Rust program is the fn main() function. This is where the program starts running.
Click to reveal answer
beginner
How do you print text to the console in Rust?
You use the println! macro to print text to the console. For example: println!("Hello, world!");
Click to reveal answer
intermediate
What does the exclamation mark (!) mean in println!?
The exclamation mark means println! is a macro, not a regular function. Macros can do things functions can't, like generating code.
Click to reveal answer
beginner
Why do Rust programs need a main function?
Rust programs need a main function because it tells the computer where to start running the code, like the front door of a house.
Click to reveal answer
beginner
What file extension do Rust source files use?
Rust source files use the .rs file extension. For example, main.rs is a common file name for the first program.
Click to reveal answer
What keyword starts the main function in Rust?
Afn
Bfunction
Cmain
Dstart
Which macro prints text to the console in Rust?
Aprintln!
Bconsole.log
Cecho!
Dprintline!
What file extension should you use for Rust source files?
A.r
B.rust
C.rt
D.rs
What does the exclamation mark (!) after println indicate?
AIt's a function
BIt's a macro
CIt's a variable
DIt's a comment
What is the purpose of the main function in Rust?
ATo define variables
BTo print text
CTo start the program
DTo import libraries
Explain how to write and run your first Rust program that prints "Hello, world!".
Think about the main function, printing, and file naming.
You got /4 concepts.
    Describe the role of macros in Rust and how they differ from functions, using println! as an example.
    Focus on syntax and purpose differences.
    You got /4 concepts.