
-----------------------------------
theanimator
Thu Feb 16, 2006 10:49 am

Qbasic help please!
-----------------------------------
I was wondering if anyone could help me with Qbasic? if so, i need help with this code: CLS
PRINT "how many stars do you want";
INPUT star
FOR i = 1 TO star
        LET star = star + 1
        PRINT "*";
        PRINT
NEXT i


basically when I run it, the program is supposed to look like this
run: how many stars do you want? input
*
**
***
****
*****
etc. depending on how many stars are inputed

-----------------------------------
codemage
Thu Feb 16, 2006 1:44 pm


-----------------------------------
You can do that with two for loops.
In Turing, it would look like:


for dummy1 : 1 .. number

    for dummy2 : 1 .. dummy1
        put "*" ..
    end for

    put ""
end for


-----------------------------------
theanimator
Thu Feb 16, 2006 5:14 pm


-----------------------------------
ok, but i need it for Qbasic. So, for two loops, how? i've tried but can't figure it out.

-----------------------------------
[Gandalf]
Thu Feb 16, 2006 5:48 pm


-----------------------------------
Oh!  BASIC!  Let's see what I remembers...

Ok, normally I shouldn't give you the answer, but this will be an exception since it is a fairly simple program.  See what I am doing and learn from it.  So here it is:
INPUT "How many stars do you want to display? "; starAmount
FOR index = 1 TO starAmount
FOR starsToPrint = 1 TO index
PRINT "*";
NEXT starsToPrint
PRINT " "
NEXT index
Note that you can have the INPUT statement on just one line.

-----------------------------------
theanimator
Fri Feb 17, 2006 8:13 am


-----------------------------------
thank you for the help. I just don't understand the nested loops so much. I am starting to understand them more tho. I might be back again for help. Thanks again.
