Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please Help :)
#1
Hello,

I am an old user of QBasic and have not used it in about 5 years and have recently started some basic programming again. I was wondering if some one could help me figure out a problem that I am having with the following code.

CLS
INPUT "ENTER VALUE"; VALUE
PRINT
PRINT "ANSWER"; ANSWER
ANSWER = VALUE * 6

When I run this very simple code the answer that I recieve is always 0. Can anyone tell me what I am doing wrong? I know this will be simple for all of you, but remeber it has been about 5 years for me. :rotfl: Big Grin
Reply
#2
it's because you're printing your answer before you make anything of it. put the answer = value * 6 in front of the print statement, like this:

CLS
INPUT "ENTER VALUE"; VALUE

ANSWER = VALUE * 6

PRINT
PRINT "ANSWER"; ANSWER
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#3
Just think about a program like a recipe. QB just follows the instructions top down, so you have to tell it to do things in the correct order.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#4
Quote:Just think about a program like a recipe. QB just follows the instructions top down, so you have to tell it to do things in the correct order.

if you don´t use gotos to do alot of jumping around in it Tongue
Reply
#5
[Image: shocked.jpg]
:o man, you must have forgot everything about programming hehe

Remember that a programming language (almost any) works from the top and down
That means that:

z = 7
print z ' prints 7 to screen
y = x * 3
x = 5
print y ' prints 21 (and not 15) to screen
print x ' prints 5 to screen

Oh well, good luck at getting into it again :wink:
Reply
#6
except Javascript incrementors.. :-?
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#7
:o :roll:
Yes I have forgot almost everything. I have been spending along time doing 3d CAD software work and learing highend programs like Pro/E and SDRC I-Deas. But now that I have time to learn programming again I plan to. I hope that you guys can provide me with all the help that I need Tongue

Thanks for the help so far!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)