Problem 560. Set defaults
Write a function that computes the volume of a cube. The function should be able to accept three inputs: the length, width, and height of a cube. If any of the three inputs are left empty or not given, they should default to value 1.
For example,
computeVolume(2,3,4)
returns 24, while
computeVolume(2,3)
returns 6, and
computeVolume(1,[],3)
returns 3
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers93
Suggested Problems
-
Find state names that end with the letter A
1187 Solvers
-
1211 Solvers
-
Replace NaNs with the number that appears to its left in the row.
3025 Solvers
-
Test if two numbers have the same digits
250 Solvers
-
Sum of diagonals elements of a matrix
224 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!