need help with simple qbasic prob

siftings81

Member
Sep 3, 2001
61
0
0
I need help with a qbasic probelm:

write a program that prompts for and reads numbers one at a time until a negative value is entered. After each number is read, indicate if the number is a duplicate of a number previously read. A maxium of 12 values will be entered.

this program seemed pretty easy at first, but I don't know how to keep track of all the previous numbers with the input. I know i have to use arrays, and it would be simple if it just read from a data statement, but it uses user imput. help please...
 

bot2600

Platinum Member
May 18, 2001
2,075
0
76
just use a counter for the array...lets use this

dim a$(12)
a=1
c=0
do while a<13
a$(a)=input$
if int(a$(a))<0 then end
for b=1 to a
if a$(b)=a$(b) then print"This repeated."
c=1
next
a=a+1
loop
if c=1 then print"There were no repeating numbers"
end

------------------------------------------------------------

Now, don't get me wrong. I don't think the code here will work, I haven't used qbasic in 1000000 years and can't remember the proper syntax for loops and etc, but the idea behind the program is correct. If you are familiar with qbasic, you can fix any little things wrong. :)

Bot