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.
program tinhtong;
var n,i : integer;
S : real;
begin
write('Nhap n: ');
readln(n);
i:=1;
S:=0;
while i<=n do
begin
S:=S+1/i;
i:=i+1;
end;
writeln('Tong S= ',S);
readln;
end.
program tinh_tong_S;
var
n, i: integer;
S: real;
begin
write('Nhap n: ');
readln(n);
S := 0;
i := 1;
while i <= n do
begin
S := S + 1 / i;
i := i + 1;
end;
writeln('Tong S la: ', S:0:2);
readln;
end.
*while..do
Program HOC24;
var i,n: integer;
s: real;
begin
write('Nhap n: '); readln(n);
i:=1;
while i<=n do
begin
s:=s+1/sqr(i);
i:=i+1;
end;
write('S= ',s:6:2);
readln
end.
Program HOC24;
var i,n: integer;
S: longint;
begin
write('Nhap N: '); readln(n);
i:=1; s:=0;
while i<=n do
begin
s:=s+i;
i:=i+2;
end;
write('S=',S);
readln
end.
program tinh_tong_S;
var
n, i, S: integer;
begin
write('Nhap n: ');
readln(n);
S := 0;
i := 1;
while i <= n do
begin
S := S + i;
i := i + 2;
end;
writeln('Tong S la: ', S);
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.
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.