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 HOC24;
var i,n: integer;
s: longint;
begin
write('Nhap n : '); readln(n);
s:=0;
for i:=1 to n do if i mod 2=0 then s:=s+i;
write('S = ',s);
readln
end.
pascal
program sum_of_evens;
var
i, n, sum: integer;
begin
write('Enter a positive integer: ');
readln(n);
sum := 0;
for i := 2 to n step 2 do
begin
sum := sum + i;
end;
writeln('The sum of even numbers from 2 to ', n, ' is ', sum);
end.
Bài 1:program sothuc;
uses crt;
var a:array[1..10] of real;s,i,j:real;
begin
s:=0;
for i:=1 to 10 do begin writeln('A[',i,']=');readln(a[i]); end;
for i:=1 to 10 do if a[i]<0 then
for j:=1 to 10 do
begin a[j]:=sqr(a[i]); s:=s+a[j]; end;
writeln('tong binh phuong cac so am la: ',s:2:2); readln;
end. (Khi nào mình kiểm tra chạy lại trên phần mềm rồi sửa lại nếu sai nhé)
Bài 2:
program soduong;
uses crt;
var a:array[1..100] of integer;s,i,n:integer;
begin
clrscr;
writeln('nhap do dai cua day');readln(n);
for i:=1 to n do begin
writeln('a[',i,']=');readln(a[i]);
if a[i] mod 2 = 0 then s:=s+a[i] end;
writeln('tong so duong trong day la',s:2:0);readln
end.
Bài 3: các số dương mà là số lẻ là sao thế bạn????
Câu 1:
Program HOC24;
var i,p: integer;
t: longint;
begin
write('Nhap P: '); readln(p);
t:=0;
for i:=1 to p do if i mod 2<>0 then t:=t+i;
write('Tong cac so le la: ',t);
readln
end.
1. Uses crt;
var n,i: integer;
begin clrscr;
readln(n);
for i:=1 to n do write(i:3);
readln;
end.
2. Uses crt;
var n,i: integer;
begin clrscr;
readln(n);
for i:=1 to n do if(i mod 2 = 0) then write(i:3);
readln;
end.
program bai1;
uses crt;
var a,b,c,s: real;
begin
clrscr;
write('nhap so thu nhat ='); readln(a);
write('nhap so thu hai ='); readln(b);
write('nhap so thu ba ='); readln(c);
s:=a+b+c;
writeln('tong ba so a,b,c =',s:4:2);
readln;
end.
program bai1;
uses crt;
var n: integer;
begin
clrscr;
write('nhap so n ='); readln(n);
if n mod 2 = 0 then
writeln('la so chan ') else
writeln('la so le ');
readln;
end.
var a:array[1..99] of integer;
i,n:integer;
s:longint;
begin
write('n = ');readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
if a[i] mod 2 <> 0 then s:=s+a[i];
end;
writeln('Tong cac so le cua day la ',s);
write('Day dao nguoc la ');
for i:=n downto 1 do
write(a[i]:8);
readln
end.
Câu 1:
uses crt;
var s,i:integer;
begin
clrscr;
s:=0;
for i:=1 to 10 do
s:=s+i;
writeln('Tong cua 10 so tu nhien dau tien la: ',s);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if a[i]>0 then inc(dem);
writeln('So luong phan tu duong la: ',dem);
readln;
end.
Câu 3:
uses crt;
var i,j:integer;
begin
clrscr;
for i:=1 to 9 do
begin
writeln('Bang nhan ',i,' la: ');
for j:=1 to 10 do
writeln(i,'*',j,'=',i*j);
delay(200);
end;
readln;
end.
program Tinh_Tong;
var n, s, i: integer;
begin
write('Nhap vao so nguyen duong n: ');
readln(n);
s := 0;
i := 1;
while i <= n do
begin
s := s + i;
i := i + 1;
end;
writeln('Tong cua ', n, ' so tu nhien dau tien la: ', s);
end.
program sum_of_naturals;
var
i, n, sum: integer;
begin
write('Enter a positive integer: ');
readln(n);
sum := 0;
for i := 1 to n do
begin
sum := sum + i;
end;
writeln('The sum of the first ', n, ' natural numbers is ', sum);
end.