bài 1:
uses crt;var n,i,j:longint;begin clrscr; write[‘Nhap n:’]; readln[n]; write[‘so chan tu 1->n la:’]; for i:=1 to n do if i mod 2=0 then write[i,’ ‘]; writeln; write[‘so le tu 1->n la:’]; for j:=1 to n do if j mod 20 then write[j,’ ‘]; readln;
end.
bài 2:
uses crt;var n,i,j,s,s1:longint;begin clrscr; write[‘Nhap n:’]; readln[n]; s1:=1; s:=0; write[‘tong cac so tu 1->n la:’]; for i:=1 to n do s:=s+i; write[s]; writeln; write[‘tich cac so tu 1->n la:’]; for j:=1 to n do s1:=s1*j; write[s1]; readln;
end.
bài 3:
uses crt;var n,i,j,s,s1:longint;begin clrscr; write[‘Nhap n:’]; readln[n]; s1:=0; s:=0; for i:=1 to n do if i mod 20 then s:=s+i; write[‘tong cac so le tu 1->n la:’,s]; writeln; for j:=1 to n do if j mod 20 then inc[s1]; write[‘co tat ca ‘,s1,’ so le’]; readln;
end.
bài 4:
uses crt;var n,i,j,s,s1:longint;begin clrscr; write[‘Nhap n:’]; readln[n]; s1:=0; s:=1; for i:=1 to n do if i mod 2=0 then s:=s*i; write[‘tich cac so chan tu 1->n la:’,s]; writeln; for j:=1 to n do if j mod 2=0 then inc[s1]; write[‘co tat ca ‘,s1,’ so chan’]; readln;
end.
Bài 10. Viết chương trình nhập vào một số nguyên N dương, hãy in ra màn hình các số chính phương có giá trị nằm trong đoạn từ 1 đến N. Code c:#include int main[] { int n, i, j; do { printf["Nhap n: "]; scanf["%d", &n]; } while[n Chủ Đề |