Pete's QBASIC Site Forum Index Pete's QBASIC Site
Return to Pete''s QBasic Site
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Multiplication simple

 
Post new topic   Reply to topic    Pete's QBASIC Site Forum Index -> News and Announcements
View previous topic :: View next topic  
Author Message
lrcvs



Joined: 10 Mar 2008
Posts: 59

PostPosted: Fri Jan 15, 2010 8:21 am    Post subject: Multiplication simple Reply with quote

'Program multiplication simple
'lrcvs
'(MU) Spain
'13 Jan 2010

'This program is based on: a * b = c >>> a = c / b

CLS

a$ = "9876543298789"
b$ = "2468013"

la = LEN(a$) + LEN(b$)
c$ = STRING$(la, "0")

FOR r = 1 TO la
FOR s = 0 TO 9
MID$(c$, r) = LTRIM$(STR$(s))
v$ = LTRIM$(STR$(VAL(c$) / VAL(b$)))
IF v$ = a$ THEN PRINT "Prog = "; VAL(c$): PRINT : PRINT "Comp = "; VAL(a$) * VAL(b$): END
IF VAL(a$) > VAL(v$) THEN MID$(c$, r) = LTRIM$(STR$(s))
IF VAL(a$) < VAL(v$) THEN MID$(c$, r) = LTRIM$(STR$(s - 1)): EXIT FOR
NEXT s
NEXT r
SLEEP
END
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Pete's QBASIC Site Forum Index -> News and Announcements All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
Protected by Anti-Spam ACP