Skip to content

Commit

Permalink
description update
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodesdev committed Jun 7, 2024
1 parent 604f7ff commit de8da4a
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions challenges/declaring-variables/description.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
In Rust, variables are immutable by default. This means that once a value is bound to a variable, it cannot be changed. This is a key feature of Rust that helps ensure safety and prevent bugs by avoiding unexpected changes to values.
## Declaring variables challenge

In this challenge, you will declare and use immutable variables in Rust. You will be given a function where you need to declare variables and use them to perform specific operations. The goal is to get comfortable with the concept of immutability and understand how to use immutable variables effectively.
Declaring variables in programming is a fundamental concept that allows you to **store and manipulate data**. Variables are used to store values that can be accessed and modified throughout the program.

## Your task
In Rust, variables are declared using the `let` keyword followed by the variable name and an optional type annotation.

Your task is to complete the given function by declaring immutable variables and using them to perform specific operations. You need to calculate the area of a rectangle and return the result.
In Rust, variables are **immutable by default**. This means that once a value is bound to a variable, it cannot be changed. This is a key feature of Rust that helps ensure safety and prevent bugs by avoiding unexpected changes to values.

## Requirements
## Your task

- Declare two immutable variables, `width` and `height`, and assign them values.
- Calculate the area of the rectangle using the formula `area = width * height`.
- Return the calculated area.
In this challenge, you will declare and use immutable variables in Rust. You will be given a function where you need to **declare variables** and use them to perform specific operations. The goal is to get comfortable with the concept of **immutability and understand how to use immutable variables effectively.**

## Example
Your task is to define two immutable variables inside the function using the `let` keyword:

```rust
fn calculate_area() -> u32 {
// Declare width and height
let width = 10;
let height = 5;
- `width` with a value of `10`
- `height` with a value of `5`

// Calculate area
let area = width * height;
Then, calculate the area of a rectangle using the formula `area = width * height` and return the calculated area.

// Return area
area
}
## Requirements

assert_eq!(calculate_area(), 50);
```
- Declare two immutable variables, `width` and `height`, and assign them values.
- Calculate the area of the rectangle using the formula `width * height`.
- Return the calculated area.

## Hints

Expand Down

0 comments on commit de8da4a

Please sign in to comment.