Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Can't find the error in my program...

Author
Message
Black Mage Masta
18
Years of Service
User Offline
Joined: 31st Jan 2006
Location: Visiting Bender in Robot Hell
Posted: 1st Feb 2006 04:27
I'm a newbie, and I'm trying to write a program to square numbers for a school project. The following is my code:

Print "Please enter a number."
Input A
B= A * A
Print "If you square " A " you get " B "."

What did I do wrong in line 4? That's where the error appears.
SirFire
19
Years of Service
User Offline
Joined: 4th Apr 2005
Location: North America
Posted: 1st Feb 2006 11:43
try
Print "If you square "+str$(A)+" you get "+str$(B)+"."

Chilled Programmer 420
19
Years of Service
User Offline
Joined: 24th Nov 2005
Location: NOT SAYING!, i dont wanna get kidnapped!
Posted: 1st Feb 2006 12:25
i think this shuld work 2, though i aint tried
print "If you square "+A+" you get "+B+"."

[url=www.freewebs.com/tyhrfg][img]bruce.bmp[/img][/url]
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 1st Feb 2006 14:42
Alternatively;



Boo!
Acolyte Entertainment
19
Years of Service
User Offline
Joined: 28th Dec 2004
Location: Oregon, US
Posted: 1st Feb 2006 15:55
black mage masta! YO! i think i get what you are trying to get at. correct me if im wrong:

you wanna create a program that gets input from the user for 1 number then multiply that number by itself a print the answer?

here is how id do it:



okay, now for an explenation:
all i did was delete your first print command. change your input to your questing and save it as "A" a real number. a real number is a number that doesent have a decimal. then i state that the letter "B" is equal to A times A. then we print:



the commas outside your print command show that the print command is continueing.

hope it helps,
~snowfall Studios

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 1st Feb 2006 18:23 Edited at: 1st Feb 2006 18:28
i think you offered this in haste, Snowfall:
Quote: "a real number is a number that doesent have a decimal."


that's an Integer, not a Real. just keeping it as accurate as possible so as not to confuse anyone.

BMM - if you want to print with quotes around A & B, like it appears in your question above, try the following:



chr$(34) is the ASCII code for " (quotation mark)

Athlon XP1800+, Windows XP+SP2, Soyo K7V Dragon+ MB, 1.5Gb 333 RAM, ATI Radeon 8700LT (128Mb)
Drivers and Updates Kept Current
Black Mage Masta
18
Years of Service
User Offline
Joined: 31st Jan 2006
Location: Visiting Bender in Robot Hell
Posted: 1st Feb 2006 19:48
Thanx, everyone! I appreciate the help!

Login to post a reply

Server time is: 2024-11-27 05:34:35
Your offset time is: 2024-11-27 05:34:35