Viết chương trình in ra các số chia hết cho 3 trong phạm vi 1-10
K
Khách
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.

Những câu hỏi liên quan

21 tháng 1 2022
#include <bits/stdc++.h>
using namespace std;
long long i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) if (i%3==0) cout<<i<<" ";
return 0;
}

6 tháng 4 2022
#include <bits/stdc++.h>
using namespace std;
long long n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
if (i%3==0) t+=i;
cout<<t;
return 0;
}

15 tháng 4 2022
uses crt;
var i,dem:integer;
begin
clrscr;
dem:=0;
for i:=1 to 50 do
if i mod 3=0 then
begin
write(i:4);
inc(dem);
end;
writeln;
writeln(dem);
readln;
end.

30 tháng 12 2021
#include <bits/stdc++.h>
using namespace std;
int t,i;
int main()
{
t=0;
for (i=1; i<=20; i++)
if ((i%3==0) and (i%2==1)) t=t+i;
cout<<t;
return 0;
}
program SoChiaHetCho3;
var
i: Integer;
begin
writeln('Cac so chia het cho 3 trong doan tu 1 den 10 la:');
for i := 1 to 10 do
begin
if i mod 3 = 0 then
write(i, ' ');
end;
end.