İ wrote a code but idk if its correct can u check it
1 次查看(过去 30 天)
显示 更早的评论
%First Program
pi=3;
kenar1=input('dikdörtgenin uzun kenarının boyunu giriniz: ');
kenar2=input('dikdörtgenin yüksekliğini giriniz: ');
alan= kenar1*kenar2;
daire=pi*(kenar2/2)^2;
alan;
alan2=alan/2-daire;
disp(['Dikdörtgenin alanı: ',num2str(alan)])
disp(['Kırmızı bölgenin alanı: ',num2str(alan2)])
0 个评论
回答(1 个)
Sam Chak
2024-3-14
The formulas are generally correct. However, there is a technical issue worth considering. Have you ever wondered why the area of the red region is 0 when the length is 3 and the height is 2?
There will be another issue after you fix it.
%First Program
pi = 3; % what is 'pie' 🥧?
side1 = 3; % input( 'Enter the length of the long side of the rectangle: ' );
side2 = 2; % input( 'Enter the height of the rectangle: ' );
area = side1*side2; % area of the rectangle
circle = pi*(side2/2)^2; % formula to calculate area of a perfect circle
area2 = area/2 - circle; % area of red region
disp(['Area of the rectangle: ', num2str(area)])
disp(['Area of the red region: ', num2str(area2)])
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!