Rust Functions and Control Flow Exercises with Solutions and Explanations
Rust Functions and Control Flow Exercises [10 exercises with solution and Explanation]
[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]
1. Write a Rust function that calculates the area of a rectangle given its width and height.
2. Write a Rust function to check if a number is prime.
3. Write a Rust program that implements two functions to find the maximum and minimum numbers in an array.
4. Write a Rust function to calculate the factorial of a given number.
5. Write a Rust function that takes a string and returns the reverse of the string.
6. Write a Rust program that implements a function to calculate the nth Fibonacci number.
7. Write a Rust function to convert a temperature value from Celsius to Fahrenheit.
8. Write a Rust program that defines a function to print the Fibonacci sequence up to a specified number of terms.
9. Write a Rust function to find the sum of all elements in an array.
10. Write a Rust function to check if a string is a palindrome.
Rust Code Editor:
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/rust/basic/functions-and-control-flow.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics