Để tính tổng S = 2 +4+6+…..+n; em chọn đoạn lệnh :
A . For i:=1 to n do If ( i mod 2 )=0 then S:=S B. For i:=1 to n do If ( i mod 2 )=1 then S:=S+i;
C. For i:=1 to n do S:=S+i; D. For i:=1 to n do If ( i mod 2 ) <> 0 then S:=S +i;
Chọn câu A
A . For i:=1 to n do If ( i mod 2 )=0 then S:=S+i;
Học tốt!
Để tính tổng S = 2 +4+6+…..+n; em chọn đoạn lệnh :
A . For i:=1 to n do If ( i mod 2 )=0 then S:=S+i;
B. For i:=1 to n do If ( i mod 2 )=1 then S:=S+i;
C. For i:=1 to n do S:=S+i;
D. For i:=1 to n do If ( i mod 2 ) <> 0 then S:=S +i;