Problem 2377. Area of a disk
Find the area of a disk or circle.
x= radius of the disk.
Solution Stats
Problem Comments
-
6 Comments
Rather than using isequal on floating points which is bad practice and forcing the function to round its output to two decimals, you should test that the result is within a certain tolerance of the true value, like so: assert(abs(y_correct-crcl_area(x)) <= 0.01)
Good advice! Floating point math and isequal don't mix well.
why don't you claim "pi"?really hate it.
"pi" works, but currently, solution needs to be rounded off to 2 decimal places.
Would be better to increase the result tolerance.
The numbers are wrong.
Please fix the test suite.
You need to specify that the answer must be rounded to 2 decimal places.
Solution Comments
Show commentsProblem Recent Solvers365
Suggested Problems
-
Omit columns averages from a matrix
606 Solvers
-
Project Euler: Problem 6, Natural numbers, squares and sums.
2498 Solvers
-
Celsius to Fahrenheit converter
648 Solvers
-
07 - Common functions and indexing 4
416 Solvers
-
Find the area of the four walls
284 Solvers
More from this Author3
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!