perimeter , area of circle
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Minh
el 30 de Sept. de 2022
Comentada: Minh
el 30 de Sept. de 2022
I am doing a code to calculate the circumference and area of a circle, but when I get the results, the answer is the circumference and area are reversed, I don't know where I am wrong?
r = input('r= ');
P = pi * 2 * r;
S = pi * (r^2);
fprintf('P = %.2f\n',S);
fprintf('S = %.2f\n',P);
0 comentarios
Respuesta aceptada
Davide Masiello
el 30 de Sept. de 2022
Editada: Davide Masiello
el 30 de Sept. de 2022
You just need to change the arguments in fprintf, since you must have accidentally swapped them.
r = 1;
P = pi * 2 * r;
S = pi * (r^2);
fprintf('P = %.2f\n',P);
fprintf('S = %.2f\n',S);
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!