tạo mảng a gom 100 phan tu viet chuong trinh tinh tong cac co co chi so le
0 bình luận về “tạo mảng a gom 100 phan tu viet chuong trinh tinh tong cac co co chi so le”
Program NN; Uses crt; Var A: array[1..100] of longint; n,i,s: longint; Begin Clrscr; Write(‘Nhap n: ‘); Readln(n); s:=0; For i:=1 to n do Begin Read(A[i]); If i mod 2 <> 0 then s:=s+A[i]; End; Write(‘S = ‘,s); Readln End.
Program NN;
Uses crt;
Var A: array[1..100] of longint;
n,i,s: longint;
Begin
Clrscr;
Write(‘Nhap n: ‘); Readln(n);
s:=0;
For i:=1 to n do
Begin
Read(A[i]);
If i mod 2 <> 0 then s:=s+A[i];
End;
Write(‘S = ‘,s);
Readln
End.