0
0
Rustprogramming~15 mins

Writing first Rust program - Mini Project: Build & Apply

Choose your learning style9 modes available
Writing first Rust program
๐Ÿ“– Scenario: You want to create a simple Rust program that greets a user by name. This is like writing a friendly note to someone, but using code.
๐ŸŽฏ Goal: Build a Rust program that stores a name, creates a greeting message using that name, and then prints the greeting.
๐Ÿ“‹ What You'll Learn
Create a variable to hold a name
Create a greeting message using the name
Print the greeting message
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Greeting messages are common in apps and websites to welcome users personally.
๐Ÿ’ผ Career
Understanding how to create variables and print output is the first step in writing any Rust program.
Progress0 / 4 steps
1
Create a variable with a name
Create a variable called name and set it to the string "Alice".
Rust
Need a hint?

Use let to create a variable and assign the string "Alice" to it.

2
Create a greeting message
Create a variable called greeting that uses format! to combine the text "Hello, " with the variable name.
Rust
Need a hint?

Use format!("Hello, {}!", name) to create the greeting string.

3
Print the greeting message
Use println! to print the variable greeting.
Rust
Need a hint?

Use println!("{}", greeting); to show the greeting on the screen.

4
Run and see the greeting
Run the program and observe the output. It should print Hello, Alice!.
Rust
Need a hint?

Use cargo run or rustc to compile and run your program.