In: Computer Science
MATLAB
Create a function that prints a string of perfect cubes between (m,n). Include any reasonable error statements such as decimals and negative numbers.
`Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
clc
clear all
m=input('Enter m: ');
if(m<0||m~=floor(m))
disp('Error! Input m is not accepted');
return;
end
n=input('Enter n: ');
if(n<0||n~=floor(n))
disp('Error! Input n is not accepted');
return;
end
fprintf('Perfect cubes are: ');
for i=m:n
if(abs(i^(1/3)-round((i)^(1/3)))<1e-10)
fprintf('%d ',i);
end
end
Kindly revert for any queries
Thanks.