Scala Control Flow: Exercises, Practice, Solutions
Scala control flow Exercises [ 10 exercises with solution ]
[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]
1. Write a Scala program to check if a given number is positive, negative, or zero using if/else statements.
Click me to see the sample solution
2. Write a Scala program to find the maximum of two given numbers using if/else statements.
Click me to see the sample solution
3. Write a Scala program to check if a given number is even or odd using if/else statements.
Click me to see the sample solution
4. Write a Scala program to find the factorial of a given number using a while loop.
Click me to see the sample solution
5. Write a Scala program to print the Fibonacci series up to a given number using a while loop.
Click me to see the sample solution
6. Write a Scala program to print the multiplication table of a given number using a for loop.
Click me to see the sample solution
7. Write a Scala program to find the sum of all elements in an array using a for loop.
Click me to see the sample solution
8. Write a Scala program to check if a given string is a palindrome using if/else statements and pattern matching.
Click me to see the sample solution
9. Write a Scala program to count the number of vowels in a given string using if/else statements and pattern matching.
Click me to see the sample solution
10. Write a Scala program to find the largest element in an array using pattern matching.
Click me to see the sample solution
More ...
Scala 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.
Test your Python skills with w3resource's quiz
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://w3resource.com/scala-exercises/control-flow/index.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics