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.
Câu 1:
uses crt;
var s,i,n:integer;
begin clrscr;
s:=0;
write('Nhap n: ');readln(n);
for i:=1 to n do
if i mod 2 <> 0 then inc(s,i);
write('Tong cac so le tu 1 den ',n,' la: ',s);
readln
end.
Câu 2:
uses crt;
var s,i,n:integer;
begin clrscr;
s:=0;
write('Nhap n: ');readln(n);
for i:=1 to n do
if i mod 2 = 0 then inc(s,i);
write('Tong cac so le tu 1 den ',n,' la: ',s);
readln
end.
program TongN;
var
n, i, tong: integer;
begin
tong := 0;
writeln('Nhap so nguyen duong N: ');
readln(n);
i := 0;
while i < n do
begin
i := i + 1;
tong := tong + i;
end;
writeln('Tong cac so tu 1 den ', n, ' la ', tong);
readln;
end.
uses crt;
var s:real;
i,n:integer;
begin
clrscr;
readln(n);
s:=0;
for i:=1 to n do
s:=s+1/(i*(i+2));
writeln(s:4:2);
readln;
end.
Tham khảo:
uses crt;
var a:array[1..5] of integer;
i,t:integer;
tb:real;
begin
for i:=1 to 5 do readln(a[i]);
t:=0;
for i:=1 to 5 do t:=t+a[i];
tb:=t/5;
write(Tb);
readln;
end.
Uses crt;
Var a,b,c,d,e,g:longint;
Begin
Clrscr;
writeln(so thu nhat la);readln(a);
writeln(so thu nhat la);readln(b);
writeln(so thu nhat la);readln(c);
writeln(so thu nhat la);readln(d);
writeln(so thu nhat la);readln(e);
g:=a+b+c+d+e;
Writeln('Tong scua 5 so la',g);
readln;
end.
uses crt;
var i,n,t:integer;
begin
clrscr;
write('nhap n='); readln(n);
t:=0;
for i:=1 to n do
if i mod 2=0 then t:=t+i;
writeln(t);
readln;
end.
uses crt;
var i,n,t:integer;
begin
clrscr;
write('nhap n='); readln(n);
t:=0;
for i:=1 to n do
if i mod 2=1 then t:=t+i;
writeln(t);
readln;
end.
Câu 1:
program Tinhtong:
var
n, i, sum: integer;
begin
write('Nhap n: ');
readln(n);
sum := 0;
for i := 2 to n do
begin
if i mod 2 = 0 then
begin
sum := sum + i;
end;
end;
writeln('Tong cac so chan tu 2 toi ', n, ' la ', sum);
readln;
end.
Câu 2:
program Tinhtong:
var
n, i, sum: integer;
begin
write('Nhap n: ');
readln(n);
sum := 0;
for i := 1 to n do
begin
if i mod 2 = 1 then
begin
sum := sum + i;
end;
end;
writeln('Tong cac so le tu 1 toi ', n, ' la ', sum);
readln;
end.
Program TinhTong;
Uses crt;
Var S,i,n:Integer; // Khai bao bien su dung
BEGIN
Write( ‘ Nhap so n:’ ); // Thong bao nhap lieu
Readln( n ); // Nhap gtri N, (voi &N la lay d/c bien N)
S: = 0; // Khoi gan gia tri ban dau cho S
For i:=1 to n do // Lap voi moi i co gia tri tu 1 den N
S:=S + i; // Tinh tong cong don i vao S
Writeln( ‘Tong = ’, S); // Xuat ket qua tong S ra man hinh
Readln;
END.