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.
tk:
https://hoc247.net/hoi-dap/tin-hoc-8/viet-chuong-trinh-tinh-tong-100-so-tu-nhien-dau-tien-faq247722.html
Program HOC24;
var n,i: integer;
t: longint;
Begin
write('Nhap N: '); readln(N);
t:=0;
for i:=1 to n do t:=t+i;
if t mod 2=0 then write('Tong la so chan') else write('Tong la so le');
readln
end.
1:
#include <bits/stdc++.h>
using namespace std;
long long dem,i,n,x;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0) dem++;
}
cout<<dem;
return 0;
}
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%3==0) t+=x;
}
cout<<t;
return 0;
}
uses crt;
var i,t:integer;
begin
clrscr;
t:=0;
for i:=1 to 20 do
t:=t+i;
writeln(t);
readln;
end.
uses crt;
var x,t,i:integer;
begin
clrscr;
t:=0;
repeat
readln(x);
t:=t+x;
until x=0;
write(t);
readln;
end.
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.
1.
program tinhtong;
uses crt;
var s,i,n:integer;
begin
s:=0;
for i:=1 to 10 do s:=s+1;
writeln ('tong cua s=',s);
readln
end.
2.
program tinhtong;
uses crt;
var i,L,s:integer;
begin
write('nhap gia tri L='); readln(L);
s:=0;
for i:=1 to L do s:=s+1;
writeln('tong cua s=',s);
readln
end.
uses crt;
var s,i:integer;
begin
clrscr;
s:=0;
for i:=1 to 20 do
if i mod 2=0 then s:=s+i;
writeln('Tong cac so chan trong khoang 20 so tu nhien dau tien la: ',s);
readln;
end.