program tong_chan;
uses crt;
var i,tong:integer;
a:array[1..10] of integer;
begin
clrscr;
writeln('nhap vao 10 so nguyen duong');
for i:=1 to 10 do
begin
write('a[',i,']=');readln(a[i]);
while a[i]<=0 do
begin
write('nhap lai a[',i,'] la so nguyen duong:');
readln(a[i]);
end;
end;
tong:=0;
for i:=1 to n do
if a[i] mod 2 = 0 then tong:=tong+a[i];
if tong= 0 then write('khong co so nguyen duong chan')
else write('tong cua ca so nguyen duong chan la:',tong);
readln;
end.![]()
chúc bạn học tốt!!![]()
Program Tinh_tong;
uses crt;
var a: array[1..100] of integer;
n, i, s: integer;
begin
clrscr;
write('nhap so n =');
readln(n);
for i:= 1 to n do
begin
write('a[',i,']=');
readln(a[i]);
end;
s:= 0;
for i:= 1 to n do
if a[i] mod 2 = 0 then
s:= s + a[i];
writeln(' Tong cac so la : ' ,s);
readln
end.