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.
Challenge: Find the average - Rust Tutorial
From the course: Rust Essential Training
Challenge: Find the average
(upbeat music) - [Instructor] All right, folks. It's time for a challenge to practice working with different data types and numeric operations in Rust. Your goal for this challenge will be to compute the arithmetic average, or mean, of three given numbers that can be calculated by adding the three numbers together and then dividing their sum by three. You should use this code from the exercise files as a starting point. It declares three variables A, B and C on lines two through four. Notice that the three variables have different data types. That's something you'll need to take into account for your solution. Your job is to replace the comment on line six with your code to calculate the arithmetic mean of A, B, and C. You should perform your calculation using 64 bit floating point values, and then assign that result to a variable named average. The assert equal macro on line eight will check to make sure the average…
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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-