Q:

Write a function that prints the area and circumference of a circle for a given radius. Only the radius is passed to the function. The function does not return any values. The area is given by π r2 and the circumference is 2 π r

0

Write a function that prints the area and circumference of a circle for a given radius. Only the radius is passed to the function. The function  does not return any values. The area is given by π r2  and the  circumference is 2 π r

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

printAreaCirc.m

function printAreaCirc(rad)

% Prints the radius, area, and circumference

% of a circle

% Format of call: printAreaCirc(radius)

% Does not return any values

fprintf('For a circle with a radius of %.1f,\n', rad)

fprintf(' the area is %.1f and the circumference is %.1f\n',...

 pi*rad*rad, 2*pi*rad)

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now