10 CLS
20 N = 10
30 DIM A(1 TO 11) AS INTEGER
40 FOR I = 1 TO N
50 INPUT "ENTER A NUMBER: ", A(I)
60 NEXT I
70 INPUT "WHICH OF THE VALUES ENTERED DO YOU WANT TO SEARCH FOR: ", ITEM
80 A(N + 1) = ITEM
90 LET COUNT = 0
100 LET LOC1 = 1
110 WHILE (A(LOC1) <> ITEM)
120 IF (LOC1 > N) THEN
130 PRINT "ITEM IS NOT IN THE ARRAY"
140 GOTO 70
150 END IF
160 IF (A(LOC1) MOD 2 <> 0) THEN
170 COUNT = COUNT + 1
180 END IF
190 LOC1 = LOC1 + 1
200 WEND
210 PRINT "LOCATION OF ITEM IS AT ARRAY INDEX ", LOC1
220 PRINT "THE NUMBER OF ODD ELEMENTS ENCOUNTERED DURING THE SEARCH IS ", COUNT
230 END
PROGRAM RESULT
0 Comments
If you have further concerns, kindly drop a comment.