Viết chương trình : 2 + 4 + 6 + .. + 2n 06/08/2021 Bởi Abigail Viết chương trình : 2 + 4 + 6 + .. + 2n
uses crt;var n , i, t : longint;begin clrscr;t:=0;write(‘Nhap n :’); readln(n);for i:=1 to 2*n do if i mod 2 = 0 then t:=t+i;write(‘Tong la :’,t);readlnend. Bình luận
program Tong_Cach_Deu; uses crt; var i,n : integer; S: longint; begin clrscr; writeln(‘ Nhap so N’) ; readln(N); S:=0 for i:=1 to n do if i mod 2=0 then S:=s+i; writeln(‘ tong cua cac so chan tu 2 den’,N,’la:’,s) end. Bình luận
uses crt;
var n , i, t : longint;
begin clrscr;
t:=0;
write(‘Nhap n :’); readln(n);
for i:=1 to 2*n do if i mod 2 = 0 then t:=t+i;
write(‘Tong la :’,t);
readln
end.
program Tong_Cach_Deu;
uses crt;
var i,n : integer;
S: longint;
begin
clrscr;
writeln(‘ Nhap so N’) ; readln(N);
S:=0
for i:=1 to n do if i mod 2=0 then S:=s+i;
writeln(‘ tong cua cac so chan tu 2 den’,N,’la:’,s)
end.