Viết chương trình in ra màn hình số lượng các số lẻ từ 1 đến N

  • lý thuyết
  • trắc nghiệm
  • hỏi đáp
  • bài tập sgk

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ự

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.

Lorem ipsum dolor sit amet, consectetur adipiscing elit.Morbi adipiscing gravdio, sit amet suscipit risus ultrices eu.Fusce viverra neque at purus laoreet consequa.Vivamus vulputate posuere nisl quis consequat.

Create an account

Video liên quan

Chủ Đề