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

Challenge: Find the average - Rust Tutorial

From the course: Rust Essential Training

Start my 1-month free trial

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…

Contents