Viết chương trình tính tổng a) S=2+4+6+…+(2*N) b) S=1+3+…+(2*N+1) c) S=1*2+2*3+…+N*(N+1) 24/07/2021 Bởi Vivian Viết chương trình tính tổng a) S=2+4+6+…+(2*N) b) S=1+3+…+(2*N+1) c) S=1*2+2*3+…+N*(N+1)
a) program ct; uses crt; var n,S,i:integer; begin clrscr; write(‘nhap n=’); readln(n); S:=0; for i:=1 to n do S:=S+2*i; writeln(‘tong=’,S); readln end. b) program ct; uses crt; var n,S,i:integer; begin clrscr; write(‘nhap n=’); readln(n); S:=0; for i:=1 to n do S:=S+(2*i+1); writeln(‘tong=’,S); readln end. c) program ct; uses crt; var n,S,i:integer; begin clrscr; write(‘nhap n=’); readln(n); S:=0; for i:=1 to n do S:=S+i*(i+1); writeln(‘tong=’,S); readln end. Bình luận
Câu a) program tinhtong; uses crt; var n,i:integer; s:longint; begin write(‘Nhap n: ‘); readln(n) s:=0; for i:=1 to n do s:=s+2*i; write(‘S= ‘,s); readln end. Câu b) program tinhtong; uses crt; var n,i:integer; s:longint; begin write(‘Nhap n: ‘); readln(n) s:=0; for i:=1 to n do s:=s+(2*i+1); write(‘S= ‘,s); readln end. Câu c) program tinhtong; uses crt; var n,i:integer; s:longint; begin write(‘Nhap n: ‘); readln(n) s:=0; for i:=1 to n do s:=s+i*(i+1); write(‘S= ‘,s); readln end. Bình luận
a)
program ct;
uses crt;
var n,S,i:integer;
begin
clrscr;
write(‘nhap n=’); readln(n);
S:=0;
for i:=1 to n do S:=S+2*i;
writeln(‘tong=’,S);
readln
end.
b)
program ct;
uses crt;
var n,S,i:integer;
begin
clrscr;
write(‘nhap n=’); readln(n);
S:=0;
for i:=1 to n do S:=S+(2*i+1);
writeln(‘tong=’,S);
readln
end.
c)
program ct;
uses crt;
var n,S,i:integer;
begin
clrscr;
write(‘nhap n=’); readln(n);
S:=0;
for i:=1 to n do S:=S+i*(i+1);
writeln(‘tong=’,S);
readln
end.
Câu a)
program tinhtong;
uses crt;
var n,i:integer;
s:longint;
begin
write(‘Nhap n: ‘); readln(n)
s:=0;
for i:=1 to n do
s:=s+2*i;
write(‘S= ‘,s);
readln
end.
Câu b)
program tinhtong;
uses crt;
var n,i:integer;
s:longint;
begin
write(‘Nhap n: ‘); readln(n)
s:=0;
for i:=1 to n do
s:=s+(2*i+1);
write(‘S= ‘,s);
readln
end.
Câu c)
program tinhtong;
uses crt;
var n,i:integer;
s:longint;
begin
write(‘Nhap n: ‘); readln(n)
s:=0;
for i:=1 to n do
s:=s+i*(i+1);
write(‘S= ‘,s);
readln
end.