Câu 2:
a) Dùng vòng lặp For...do
uses crt;
var i,s:integer;
begin
clrscr;
s:=0;
for i:=1 to 50 do
s:=s+i;
writeln('Tong 50 so tu nhien dau tien la: ',s);
readln;
end.
b) Dùng vòng lặp While...do
uses crt;
var i,s:integer;
begin
clrscr;
s:=0;
i:=1;
while i<=50 do
begin
s:=s+i;
inc(i);
end;
writeln('Tong 50 so tu nhien dau tien la: ',s);
readln;
end.
Câu 3:
uses crt;
var n,i,dem:integer;
a:array[1..100]of integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if a[i] mod 2=0 then inc(dem);
writeln('So cac so chan la: ',dem);
readln;
end.