Using QBASIC:
A. Using the following "data-list" containing twenty numbers, count
how many of the numbers are:
1. Positive
2. Negative
3. Zero
B. Use "Read" and "Data" statements
DATA: 10,2,0,-6,5,72,60,61,4,-80,-14,90,89,100,-42,17,55,48,21
-need trip code ...make trip code last number
Run ...should look like this
Pos. Neg. Zero
15 4 1 |
Clarification of Question by
higgins911-ga
on
15 Nov 2004 09:16 PST
This is what I came up with so far.
CLS
DIM posnum AS INTEGER
DIM negnum AS INTEGER
DIM zernum AS INTEGER
posnum = 0
negnum = 0
zernum = 0
IF X = -1 THEN GOTO NOMORE
FOR X = 1 TO 21
READ X
DATA 10,2,0,-6,5,72,60,61,4,-80,-14,90,89,100,-42,17,55,48,21,-1
FOR Y = 1 TO 21
NEXT Y
NEXT X
IF X > 0 THEN
posnum = posnum + 1
ELSEIF X < 0 THEN
negnum = negnum + 1
ELSEIF X = 0 THEN
zernum = zernum + 1
ELSE
PRINT "ERROR"
END IF
PRINT "POSTIVE "; "NEGATIVE "; "ZERO"
PRINT posnum, negnum, zernum
NOMORE:
END
|