Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
![](https://rs.olm.vn/images/avt/0.png?1311)
Câu 8.
program im_14424;
uses crt;
var S: byte;
i: byte;
begin
clrscr;
S:=0;
for i:=1 to 20 do
S:=S+i;
writeln('Tong cua 20 so tu nhien dau tien la: ,S);
readln
end.
Câu 9.
j:=2 → Gán j = 2.
for i:=1 to 5 do → lặp lại 5 lần
j:=j+2 →
Lần 1: 4
Lần 2: 6
Lần 3: 10
Lần 4: 12
Lần 5: 14
Câu 1:
uses crt;
var sum,i:longint;
begin
clrscr;sum:=0;
for i:=1 to 20 do sum:=sum+i;
write(sum);
readln
end.
Câu 2:
i = 1; j = 4i = 2; j = 6i = 3; j = 8i = 4; j = 10i = 5; j = 12
![](https://rs.olm.vn/images/avt/0.png?1311)
For...do:
var s,i: integer;
begin
readln(s,i);
s:=0;
For i:=3 to 99 do
If i mod 3 = 0 do s:=s+i;
write(s)
readln;
end.
while ... do:
Var i,S:integer;
Begin
Readln(i,s);
S:=0;
i:=3;
while i<=99 do
if i mod 3 = 0 then s:=s+i;
write(s);
Readln;
End.
![](https://rs.olm.vn/images/avt/0.png?1311)
lệnh for...to...do:
a)program tinh_tong;
uses crt;
var i,s:byte;
begin
clrscr;
s:=0;
for i:=1 to 9 do s:=s+i;
write(s);
readln;
end.
b)
program tinh_tong;
uses crt;
var i,s:byte;
begin
clrscr;
s:=0;
for i:=1 to 14 do
begin
if i mod 2=0 then
s:=s+i;
end;
write(s);
readln;
end.
c)
program tinh_tong;
uses crt;
var i,s:byte;
begin
clrscr;
s:=0;
for i:=1 to 15 do
begin
if i mod 2=1 then
s:=s+i;
end;
write(s);
readln;
end.
lệnh while...do
a)program tinh_tong;
uses crt;
var i,s:byte;
begin
clrscr;
s:=0;
i:=1;
while i<=9 do
begin
s:=s+i;
i:=i+1;
end;
write(s);
readln;
end.
b)program tinh_tong;
uses crt;
var i,s:byte;
begin
clrscr;
s:=0;
i:=1;
while i<=14 do
begin
if i mod 2=0 then
s:=s+i
else i:=i+1;
end;
write(s);
readln;
end.
c)
program tinh_tong;
uses crt;
var i,s:byte;
begin
clrscr;
s:=0;
i:=1;
while i<=15 do
begin
if i mod 2=1 then
s:=s+i
else i:=i+1;
end;
write(s);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
program tong_for_to_do;
uses crt;
var i,n:integer;
t:real;
begin
clrscr;
write('nhap n:');readln(n);
t:=0;
for i:=1 to n do
if i mod 3=0 then t:=t+1/i;
writeln('tong la: ',t);
readln;
end.
program tong_while_do;
uses crt;
var i,n:integer;
t:real;
begin
clrscr;
write('nhap n:');readln(n);
t:=0;i:=3;
while i<=3*n do
begin
t:=t+1/i;
i:=i+3;
end;
writeln('tong la: ',t);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
b)
uses crt;
var i,n:integer;
t:real;
begin
clrscr;
write('Nhap n='); readln(n);
i:=1;
t:=0;
while i<=n do
begin
t:=t+1/(i*(i+3));
i:=i+1;
end;
writeln(t:4:2);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
var i,t:integer;
begin
clrscr;
t:=0;
for i:=1 to 100 do t:=t+i;
writeln(t);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
var i,t:integer;
begin
clrscr;
t:=0;
for i:=1 to 100 do t:=t+i;
writeln(t);
readln;
end.
a: uses crt;
var i,n:integer;
s:real;
begin
clrscr;
s:=0;
for i:=1 to 100 do s:=s+1/i;
writeln(s:4:2);
readln;
end.
b:
uses crt;
var i,n:integer;
s:real;
begin
clrscr;
s:=0;
i:=0;
while i<=100 do
begin
inc(i);
s:=s+1/i;
end;
writeln(s:4:2);
readln;
end.