Hi, I am having some trouble with a Qbasic code that's supposed to print a pyramid looking like 0
1 0 1
2 1 0 1 2
3 2 1 0 1 2 3
etc using a nested if statement. I'm very new at this and I would like any help possible. Thanks!
help for a beginner
This seems to work! All integers and in no way optimised.
If you require a true pyramid shape you will have to space out to the print position - use max as the spacing control.
max = 8 'Set no. of lines
CLS
PRINT " 0" 'First line
FOR x = 1 TO max
y = x 'Going up
WHILE y <> 0
PRINT y;
y = y - 1
WEND
PRINT " 0 "; 'Middle zero
y = 1 'Going down
WHILE y <> x + 1
PRINT y;
y = y + 1
WEND
PRINT 'Release line
NEXT x
Regards,
Eevee
If you require a true pyramid shape you will have to space out to the print position - use max as the spacing control.
max = 8 'Set no. of lines
CLS
PRINT " 0" 'First line
FOR x = 1 TO max
y = x 'Going up
WHILE y <> 0
PRINT y;
y = y - 1
WEND
PRINT " 0 "; 'Middle zero
y = 1 'Going down
WHILE y <> x + 1
PRINT y;
y = y + 1
WEND
PRINT 'Release line
NEXT x
Regards,
Eevee
Ok, homework begg.. err, i mean, new person wanting to learn QB...
1) Pay attention in class
2) Pay attention in class
3) See #2
4) http://forum.qbasicnews.com/viewtopic.p ... ht=pyramid
I hate homework beggers.. atleast try to make it so not obvious... gee
Fail class.
1) Pay attention in class
2) Pay attention in class
3) See #2
4) http://forum.qbasicnews.com/viewtopic.p ... ht=pyramid
I hate homework beggers.. atleast try to make it so not obvious... gee
Fail class.
I have left this dump.
In the great, educated, freedom fighting, world police, greatest democracy (err... republic, but nevermind) The US...
Flight to New York:
"This is your captain speaking. We are now traveling 100 years back in time, to an age when we still used pounds, and gallons, and miles... The metric system is yet to be discovered"
Flight to New York:
"This is your captain speaking. We are now traveling 100 years back in time, to an age when we still used pounds, and gallons, and miles... The metric system is yet to be discovered"
I have left this dump.