![](https://rs.olm.vn/images/avt/0.png?1311)
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)
![](https://rs.olm.vn/images/avt/0.png?1311)
refer:
uses crt;
var s,i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
for i:=0 to n do
if i mod 2=0 then s:=s+i;
writeln('S=',s);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
Bạn kham khảo bài của mình nhé!
Program nhap_so_n;
Uses crt;
Var i,n,s:integer;
Begin clrscr;
Write('Nhap so n= ');Readln(n);
S:=0;
For i:=1 to n do
If i mod 2 = 0 do S:=S+i;
Writeln;
Write('tong cac so chan la ',S);
Readln;
End.
Mình chúc bạn học tốt!
![](https://rs.olm.vn/images/avt/0.png?1311)
#include <bits/stdc++.h>
using namespace std;
long long i,n,s;
int main()
{
cin>>n;
s=0;
for (i=1; i<=n; i++)
if (i%2==0) s=s+i;
cout<<s;
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
Câu 2:
#include <bits/stdc++.h>
using namespace std;
double p1,p2;
int i,n;
int main()
{
cin>>n;
p1=1;
p2=1;
for (i=1; i<=n; i++)
{
if (i%2==0) p2=p2*(i*1.0);
else p1=p1*(i*1.0);
}
cout<<fixed<<setprecision(2)<<p1<<endl;
cout<<fixed<<setprecision(2)<<p2;
return 0;
}
![](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)
program TinhTong;
var n, s,i: integer;
begin
write('Nhap vao n: ');
readln(n);
s := 0;
for i := 5 to n step 5 do
begin
s := s + i;
end; writeln('Tong cua day so la: ',s);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
![](https://rs.olm.vn/images/avt/0.png?1311)
1.
Var i ,n : integer;
S , T : real;
Begin
Write ('n:') ;
Read (n) ;
S:= 0;
T:= 1;
For i:= 1 to n do
S:= S + i;
T:= T * i;
Writeln (' Tong cua ' ,n,' , S );
Writeln (' Tich của ' ,n,', T );
Readln;
End.
2.
program SumAndProductOfNumbers;
var
n, m, i, sum, product: integer;
begin
writeln('Enter the values of n and m: ');
readln(n, m);
sum := 0;
product := 1;
for i := n to m do
begin
sum := sum + i;
product := product * i;
end;
writeln('The sum of numbers from ', n, ' to ', m, ' is: ', sum);
writeln('The product of numbers from ', n, ' to ', m, ' is: ', product);
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
Câu 1:
var i,n:integer;
s:longint;
begin
write('Nhap n = ');readln(n);
for i:=1 to n do
s:=s+(i*10+2);
write('S = ',s);
readln;
end.
Câu 2:
var i,n:integer;
s:real;
begin
write('Nhap n = ');readln(n);
for i:=1 to n do s:=s+1/n;
write('tong la ',s:10:2);
readln;
end.