Câu 2 : Hãy viết chương trình con kiểm tra tính chẵn lẻ của 1 số nguyên k? *
0 bình luận về “Câu 2 : Hãy viết chương trình con kiểm tra tính chẵn lẻ của 1 số nguyên k? *”
uses crt; var k:integer; {—Chuong-trinh-con—} procedure chan; begin write(k,’ la so chan’); end; procedure le; begin write(k,’ la so le’); end; {—Chuong-trinh-chinh—} BEGIN clrscr; write(‘Nhap so nguyen k: ‘); readln(k); if k mod 2=0 then chan else le; readln; END.
Program So_chan_le; Uses Crt; Var so,du:Integer; Begin Clrscr; Writeln(‘SO CHAN HAY SO LE’); Writeln(‘—————–‘); Write(‘-Nhap mot so nguyen bat ky: ‘); Readln(so); du:=so Mod 2; Case du Of 0:Begin Writeln(‘-So : ‘,so); Writeln(‘-La so chan’); End; 1:Begin Writeln(‘-So : ‘,so); Writeln(‘-La so le’); End; End; Writeln; Writeln(‘ Bam phim <Enter> de ket thuc’); Readln; End.
uses crt;
var k:integer;
{—Chuong-trinh-con—}
procedure chan;
begin
write(k,’ la so chan’);
end;
procedure le;
begin
write(k,’ la so le’);
end;
{—Chuong-trinh-chinh—}
BEGIN
clrscr;
write(‘Nhap so nguyen k: ‘); readln(k);
if k mod 2=0 then chan
else le;
readln;
END.
Program So_chan_le;
Uses Crt;
Var
so,du:Integer;
Begin
Clrscr;
Writeln(‘SO CHAN HAY SO LE’);
Writeln(‘—————–‘);
Write(‘-Nhap mot so nguyen bat ky: ‘);
Readln(so);
du:=so Mod 2;
Case du Of
0:Begin
Writeln(‘-So : ‘,so);
Writeln(‘-La so chan’);
End;
1:Begin
Writeln(‘-So : ‘,so);
Writeln(‘-La so le’);
End;
End;
Writeln;
Writeln(‘ Bam phim <Enter> de ket thuc’);
Readln;
End.
$Nocopy$
$An$
Cho mik xin ctrlhn nhoa!!!