From the course: Rust Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Arithmetic operations - Rust Tutorial
From the course: Rust Essential Training
Arithmetic operations
- [Instructor] Rust provides the standard set of arithmetic operations you can expect from any programming language, including addition, subtraction, multiplication, division and the modulo operator. The code shown here demonstrates the addition operator which we've already used in a previous video. After initializing the variables "a" and "b" for the integer values 10 and three, line four uses the plus symbol to add those variables together and then the equals symbol which is the assignment operator, assigns the result to the variable "c." When I run this program, the print line macro on line five says that the value of c is 13. Now, changing the plus symbol on line four to a minus symbol will subtract b from a. When I run the program now, we see that 10 minus three is seven. If we want to multiply the variables a and b, we can use the asterisk symbol, which is the multiplication operator. Running that program…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Declaring variables5m 46s
-
(Locked)
Integer data types6m 51s
-
(Locked)
Floating-point data types5m 34s
-
(Locked)
Arithmetic operations6m 37s
-
(Locked)
Formatting print statements5m 40s
-
Bitwise operations10m 46s
-
(Locked)
Boolean data type and operations5m 4s
-
(Locked)
Comparison operations3m 5s
-
Char data types2m 36s
-
(Locked)
Challenge: Find the average1m 20s
-
(Locked)
Solution: Find the average3m 20s
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-