Create a function that returns the square and the squareroot
Create a function that returns the square and the squareroot of a number supplied by the script or command line that calls it. Make sure the output includes a statement u indicate which is which.
Solution
function [sq,srt]= sqt(n)
sq= n.^2;
srt=sqrt(n);
disp([\'square of \' num2str(n) \' is \' num2str(sq)]);
disp([\'square root of \' num2str(n) \' is \' num2str(srt)]);
%result
square of 5 is 25
square root of 5 is 2.2361
t =
25
r =
2.2361
