help for a beginner

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
merrick

help for a beginner

Post by merrick »

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!
eevee

Post by eevee »

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
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

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.
I have left this dump.
Guest

Post by Guest »

Oh dear!

Did I get it wrong?

Shouldn't they have a badge or something??

Regards,

Eevee
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

:oops: i didnt even try your code Eevee

sorry, it probably works though...


I doubt merrick will be coming back anytime soon, or at all :P
I have left this dump.
Guest

Post by Guest »

I wasn't referring to the code .but ...........

..... to an inability to spot homework beggars!

Regards,

Eevee
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Oh...

Well we all miss one once in a while :wink:



Well, tell you what, I can join your party, and we can go gain some exp, until you gain an extra skill in "Homweork beggar spotting" :D
How does that sound?
I have left this dump.
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

Count me in. Also, tell me. WHERE THE HECK WOULD YOUR HOMEWORK INVOLVE USING QBASIC???!!!
Image
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

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"
I have left this dump.
Post Reply