I’m a fresher here who has just finished the matlab onramp course but unable is stuck at the practise problem.
Question:Given two input variables r and h, which stand for the radius and height of a cake, calculate the surface area of the cake you need to put frosting on (all around the sides and the top).And this is my answer:
function SA = func_frosting(r, h)
SA = (pi * r * r) + (2 * pi * r * h);
end
radius = 5;
height = 10;
surfaceArea = func_frosting(radius, height);
disp([‘The surface area of the cake is ‘, num2str(surfaceArea), ]);
But it just passes one of the four code test.Please help.Question:Given two input variables r and h, which stand for the radius and height of a cake, calculate the surface area of the cake you need to put frosting on (all around the sides and the top).And this is my answer:
function SA = func_frosting(r, h)
SA = (pi * r * r) + (2 * pi * r * h);
end
radius = 5;
height = 10;
surfaceArea = func_frosting(radius, height);
disp([‘The surface area of the cake is ‘, num2str(surfaceArea), ]);
But it just passes one of the four code test.Please help. Question:Given two input variables r and h, which stand for the radius and height of a cake, calculate the surface area of the cake you need to put frosting on (all around the sides and the top).And this is my answer:
function SA = func_frosting(r, h)
SA = (pi * r * r) + (2 * pi * r * h);
end
radius = 5;
height = 10;
surfaceArea = func_frosting(radius, height);
disp([‘The surface area of the cake is ‘, num2str(surfaceArea), ]);
But it just passes one of the four code test.Please help. function, code test, failed MATLAB Answers — New Questions