Viết chương trình tính tổng số lẻ từ 1->10 09/08/2021 Bởi Ivy Viết chương trình tính tổng số lẻ từ 1->10
Program BTH;uses crt;var i,s:longint;Begin i:=1; While i<>10 do Begin If i mod 2=1 then s:=s+i; i:=i+1; end; writeln(‘Tong day so tren la: ‘,s); readln;end. Bình luận
Program tinh_tong; Uses crt; Var S,i: byte; Begin S:=0; For i:=1 to 10 do If i mod 2 <>0 then S:= S+i; Writeln (‘Tong cac so le tu 1 den 10 la:’,S); Readln End. Bình luận
Program BTH;
uses crt;
var i,s:longint;
Begin
i:=1;
While i<>10 do
Begin
If i mod 2=1 then s:=s+i;
i:=i+1;
end;
writeln(‘Tong day so tren la: ‘,s);
readln;
end.
Program tinh_tong;
Uses crt;
Var S,i: byte;
Begin
S:=0;
For i:=1 to 10 do
If i mod 2 <>0 then
S:= S+i;
Writeln (‘Tong cac so le tu 1 den 10 la:’,S);
Readln
End.