Quick Basic in Application

Archive for March 6th, 2009

Print out Prime Numbers

Posted by: programmervb on: March 6, 2009

‘ look at a series of numbers and print out the prime numbers
‘ prime numbers are divisible only by unity or themselves
‘ this is BCX basic, a modern successor to Qbasic
Dim A    ‘ defaults to integer
For A = 1 To 100
If IsPrime(A) Then Print A;
Next
Pause   ‘ make console wait
Function IsPrime(Num)
Local X
‘ make exeptions for unity [...]

Tags:

Qbasic Character Counter

Posted by: programmervb on: March 6, 2009

DECLARE SUB GetWords (st$, wds%)
st$ = “Hello my name is John Doe”
IF RIGHT$(st$, 1) <> ” ” THEN st$ = st$ + ” “
FOR k% = 1 TO LEN(st$)
IF MID$(st$, k%, 1) = ” ” THEN words% = words% + 1
characters% = characters% + 1
NEXT
PRINT “total characters=”; characters%
PRINT “total words=”; words%
xst$ = “Hello my name [...]

Tags: