Qbasicnews.com August 06, 2020, 10:50:33 AM  Pages: Author Topic: Ten lines (Collection)  (Read 7317 times)
lrcvs
Member Posts: 56 « on: January 16, 2010, 06:24:58 PM »

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

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

CLS

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

'a * b

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 "Program = "; VAL(c\$): PRINT : PRINT "Computer = "; VAL(a\$) * VAL(b\$): END
IF VAL(a\$) < VAL(v\$) THEN MID\$(c\$, r) = LTRIM\$(STR\$(s - 1)): EXIT FOR
NEXT s
NEXT r
SLEEP
END

\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$

'Program arithmetic division with integers numbers
'lrcvs
'(MU) Spain
'09 Jan 2010

CLS
a\$ = "9876598743014313"
b\$ = "388798006"

'A/B

la = LEN(a\$)
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 VAL(v\$) = VAL(a\$) THEN PRINT v\$: EXIT FOR
IF VAL(a\$) < VAL(v\$) THEN MID\$(c\$, r) = LTRIM\$(STR\$(s - 1)): EXIT FOR
NEXT s
NEXT r

r\$ = LTRIM\$(STR\$(VAL(a\$) - (VAL(c\$) * VAL(b\$))))
d\$ = LTRIM\$(STR\$(VAL(r\$) / VAL(b\$)))

PRINT "Program = "; LTRIM\$(STR\$(VAL(c\$))) + " . " + RIGHT\$(d\$, LEN(d\$) - 1)
PRINT
PRINT "Remanence = "; r\$
PRINT
PRINT "Computer = "; VAL(a\$) / VAL(b\$)
SLEEP
END

\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$

'Program square root
'lrcvs
'(MU) Spain
'12 Jan 2010

CLS

'a\$ = number to square root

a\$ = "25521342100008787"

la = INT(LEN(a\$) / 2) + 1
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(c\$)))
IF VAL(a\$) < VAL(v\$) THEN MID\$(c\$, r) = LTRIM\$(STR\$(s - 1)): EXIT FOR
NEXT s
NEXT r

t\$ = LTRIM\$(STR\$(VAL(a\$) - (VAL(c\$) * VAL(c\$))))
d\$ = LTRIM\$(STR\$(VAL(t\$) / (VAL(c\$)) / 2))

PRINT "Square root of = "; a\$
PRINT
PRINT "Program = "; LTRIM\$(STR\$(VAL(c\$))) + " . " + RIGHT\$(d\$, LEN(d\$) - 1)
PRINT
PRINT "Remanence = "; t\$
PRINT
PRINT "Computer = "; SQR(VAL(a\$))
SLEEP
END

\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$ Logged
arockstar
New Member

Posts: 1 « Reply #1 on: May 12, 2011, 04:43:35 PM »

Ya Its A One Of The Best And Simple Method For It I Am Also Want To Follow It But Its Did Creted By You Is The Same Thin Which I Want To Create So Good And Nice Logged
lrcvs
Member Posts: 56 « Reply #2 on: May 12, 2011, 07:10:46 PM »

Thank you for your good opinion.!

This program is free, use it well.

It was fun doing this program, I hope you like.

Greetings!!! Logged
 Pages: