Viết chương trình nhập vào một số nguyên n. in ra màn hình tổng các số chẵn từ 1 đến n.
Nêu các bước đặt lề và hướng giấy in (Tin học - Lớp 7)
2 trả lời Lệnh lặp nào sau đây là đúng (Tin học - Lớp 8) 1 trả lời Viết chương trình tính tổng sau (Tin học - Lớp 8) 1 trả lời Định dạng kí tự là gì (Tin học - Lớp 7) 2 trả lời Hãy nêu cú pháp khai báo biến mảng trong pascal (Tin học - Lớp 8) 1 trả lời Có bao nhiêu dân số trên thế giới (Tin học - Lớp 5) 3 trả lời 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 2<>0 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 2<>0 then s:=s+i; write(‘tong cac so le 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 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 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 2<>0 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 2<>0 then s:=s+i; write('tong cac so le 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 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.
Viết chương trình và in ra màn hình các số chẵn từ 1 đến n , n là số tự nhiên nhập từ bàn phím. Các câu hỏi tương tự |