a)
Program Chu_nhat
uses crt
Var a, b, S, CV: real
Begin Write('Nhap chieu dai:')
readln(a)
Write('Nhap chieu rong:')
readln(b)
S := a*b
CV := (a+b)*2
Writeln('Dien tich hinh chu nhat la:',S)
Writeln('Chu vi hinh chu nhat la:',CV:10:2)
readln
end.
Chương trình tính diện tích và chu vi hình chữ nhật
Program Chu_Nhat_Program;
Uses Crt;
Var a,b,s,c: real;
Begin
Clrscr;
Writeln(‘ TINH DIEN TICH & CHU VI HINH CHU NHAT:’);
Write(‘Nhap chieu dai=’); readln(a);
Write(‘Nhap chieu rong=’);readln(b);
s:=a*b;
c:=(a+b)*2;
Writeln(‘Dien tich hinh chu nhat la:’,s:6:2); Writeln(‘Chu vi hinh chu nhat:’,c:6:2); Readln;
End.
Chương trình tính diện tích và chu vi hình tam giác
Program Hinh_Tamgiac_Program;
Uses crt;
Var a,b,c,s,p : real;
Begin
Clrscr;
Writeln(‘HINH TAM GIAC:’);
Write(‘nhap a =’);readln(a);
Write (‘nhap b =’);readln(b); Write(‘nhap c =’);readln(c);
If ((a+b)>c)and((b+c)>a)and((a+c)>b) then
Begin
p:=(a+b+c)/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c)); Writeln(‘Chu vi tam giac:’,2*p:4:2) ; Writeln(‘Dien tich tam giac:’,s:4:2);
End
Else
Writeln(a,’, ‘, b,’, ‘, c, ‘ khong phai la ba canh cua tam giac’) ;
Readln;
End.
Viết chương trình tính:
a) Diện tích hình chữ nhật, chu vi hình chữ nhật
Program Chu_Nhat_Program;
Uses Crt;
Var a,b,s,c: real;
Begin
Clrscr;
Writeln(‘ TINH DIEN TICH & CHU VI HINH CHU NHAT:’);
Write(‘Nhap chieu dai=’); readln(a);
Write(‘Nhap chieu rong=’);readln(b);
s:=a*b;
c:=(a+b)*2;
Writeln(‘Dien tich hinh chu nhat la:’,s:6:2); Writeln(‘Chu vi hinh chu nhat:’,c:6:2); Readln;
End.
b) Chu vi và diện tích tam giác
Program Hinh_Tamgiac_Program;
Uses crt;
Var a,b,c,s,p : real;
Begin
Clrscr;
Writeln(‘HINH TAM GIAC:’);
Write(‘nhap a =’);readln(a);
Write (‘nhap b =’);readln(b); Write(‘nhap c =’);readln(c);
If ((a+b)>c)and((b+c)>a)and((a+c)>b) then
Begin
p:=(a+b+c)/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c)); Writeln(‘Chu vi tam giac:’,2*p:4:2) ; Writeln(‘Dien tich tam giac:’,s:4:2);
End
Else
Writeln(a,’, ‘, b,’, ‘, c, ‘ khong phai la ba canh cua tam giac’) ;
Readln;
End.
a)
* diện tích hcn:
program dien_tich_hcn ;
uses crt ;
var a , b , S : real ;
begin
clrscr;
write ( 'a , b:');
readln ( a, b ) ;
S := a*b;
write ( ' dien tich hinh chu nhat la :', S : 20 : 4 );
readln
end.
* chu vi hcn
program chu_vi_hcn ;
uses crt ;
var a , b , P : real ;
begin
clrscr;
write ( 'a , b:');
readln ( a, b ) ;
P := a+b;
write ( ' chu vi hinh chu nhat la :', P : 5 : 4 );
readln
end.
a) program hcn;
uses crt;
var a,b,cv,s:real;
begin
clrscr;
write('nhap canh a:');readln(a);
write('nhap canh b:');readln(b);
s:=a*b;
cv:=(a+b)*2;
writeln('chu vi la:',cv:10:2);
writeln('dien tich la:',s:10:2);
readln
end.
b)program htg;
uses crt;
var a,b,c,p,s,cv:real;
begin
clrscr;
write ('nhap canh a=');readln(a);
write('nhap canh b=');readln(b);
write('nhap canh c=');readln(c);
cv:=a+b+c;
p:=cv/2;
s:=sqrt(p*(p-a)*(p-b)*(p-c));
writeln('chu vi la:',cv:10:2);
writeln('dien tich la:',s:10:2);
readln
end.