1. Để đếm có bao nhiêu số lẻ nhỏ hơn hay bằng n, chúng ta chọn lệnh nào sau đâu:
A. For i:=1 to n do if ( i mod 2 ) = 0 then s:=s+1;
B. For i:=1 to n do if ( i mod 2 ) < > 0 then s:=s+1;
C. For i:=1 to n do if ( i mod 2 ) = 0 then s:=s+I;
C. For i:=1 to n do if ( i mod 2 ) = 1 then s:=s+I;
2. Câu lệnh nào sau đây lặp vô hạn lần:
A. s:=5; i:=1; While i>s do i:=i+1;
B. s:=5; i:=0; While i<=s do s:=s+1;
C. s:=5; i:=1; While i<=s do i:=i+1;
D. s:=5; i:=0; While i<>s do i:=i+1;s:=s+i;
3. Để tính tổng S=2+4+6+..+n; em chọn lệnh nào:
A. For i:=1 to n do if ( i mod 2 ) = 0 then S:=S+i;
B. For i:=1 to n do S:=S+i;
C. For i:=1 to n do if ( i mod 2 ) = 1 then S:=S+i;
C. For i:=1 to n do if ( i mod 2 ) < > 0 then S:=S+i;
1. B
2. B
3. A
Học tốt!
1.B
2.B
3.A
${Oken}$