Tuesday, August 13, 2019

Sorting Programs in Turbo Basic

Here is a menu is driven sorting programs in BASIC that I wrote  21 years ago during my college day I used Turbo Basic as my basic compiler in writing, testing and running this program.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com








Sample Program Output


Program Listing


REM NAME OF PROJECT : SORTING TECHNIQUES
REM DATE FINISHED        : SEPTEMBER 19, 1998
REM AUTHOR                   : JAKE RODRIGUEZ POMPERADA

CLS
100
COLOR 10
PRINT
PRINT
FOR C = 1 TO 28
PRINT CHR$(205);
NEXT C
PRINT
print TAB(5) " SORTING TECHNIQUES"
PRINT TAB(8) " MAIN MENU "
FOR C = 1 TO 28
PRINT CHR$(205);
NEXT C
COLOR 11
PRINT
PRINT
PRINT " [1] System Date & Time "
PRINT " [2] Bubble Sort "
Print " [3] Insertion Sort"
PRINT " [4] Selection Sort "
PRINT " [5] Quicksort"
PRINT " [6] Mergesort "
PRINT " [7] Quit / Exit Program"
PRINT " "
FOR C = 1 TO 28
PRINT Chr$(205);
NEXT C
print
input "Enter Your Choice => ",a

IF ( A > 7 OR A < 1) THEN GOTO 105

IF A = 1 THEN
 CLS
 GOTO 110
 END IF

IF A = 2 THEN
  CLS
  GOTO 210
  END IF

IF A = 3 THEN
  CLS
  GOTO 310
  END IF

IF A = 4 THEN
  CLS
  GOTO 410
  END IF

IF A = 5 THEN
  CLS
  GOTO 510
  END IF

IF A = 6 THEN
  CLS
  GOTO 610
  END IF


IF A = 7 THEN
  CLS
 FOR C = 1 TO 75
 PRINT CHR$(205);
 delay .03
 NEXT C
 LOCATE 3,28:  Print "Exit Program To DOS..."
 LOCATE 5,29:  Print "Designed By: Servo"
 FOR C = 1 TO 75
 PRINT CHR$(205);
 delay .03
 NEXT C
 REM  THE KEYWORD SYSTEM EXIT PROGRAM TO DOS !!!
 SYSTEM
 END IF


105
PRINT
FOR C = 1 TO 75
PRINT CHR$(205);
NEXT C
color 31
LOCATE 20,29: PRINT "Invalid Option !!!"
LOCATE 21,23: PRINT "Choose Only Options [1/2/3/4/5/6/7]"
BEEP
FOR C = 1 TO 75
color 11
PRINT CHR$(205);
NEXT C
DELAY 1.5
CLS
GOTO 100

110
CLS
FOR C = 1 TO 28
PRINT CHR$(205);
NEXT C
print
PRINT TAB(3) "SYSTEM DATE AND TIME :"
FOR C = 1 TO 28
PRINT CHR$(205);
NEXT C
print
print
COLOR 15
PRINT "Date :" ,Date$
PRINT "Time :" ,Time$
DELAY 3
CLS
GOTO 100

210
REM BUBBLE SORT MODULE
CLS
DIM A(100)
COLOR 15
FOR F = 1 TO 20
PRINT "=";
NEXT F
PRINT
PRINT " BUBBLE SORT MODULE"
FOR G = 1 TO 20
PRINT "=";
NEXT G
PRINT
PRINT
Input "How many inputs :",A
FOR I = 1 To A
PRINT "Item #";i;
INPUT A(i)
NEXT I
Let N = I - 1
For J = 1 To N - 1
For I = 1 To N-J
If a(i) <= A(i+1) then 270
Let T=A(I)
Let A(i)=A(i+1)
Let A(i+1)=T
270 Next I
Next J
print
print " Sorted List of";a; "items"
PRINT
For I = 1 To N
Print a(i)" ";
next I
delay 3
cls
goto 100
end

310
REM INSERTION SORT MODULE
CLS
Dim B(100)
COLOR 15
FOR F = 1 TO 22
PRINT "=";
NEXT F
PRINT
PRINT "INSERTION SORT MODULE"
FOR F = 1 TO 22
PRINT "=";
NEXT F
PRINT
PRINT
Input "How many inputs :",a
for i = 1 To a
print "Item #";i;
input B(i)
next i
Let N = I - 1
For I = 1 To N - 1
Let J = I
Let T = B(I+1)
540 If J < 1 then 590
IF T >= B(J) THEN 590
Let B(J+1)=B(J)
Let J = J -1
Goto 540
590 Let B(J+1)=T
Next I
Print
print " Sorted List of";a; "items"
PRINT
For I = 1 To N
Print B(i)" ";
NEXT I
DELAY 3
CLS
GOTO 100
END

410
REM SELECTION SORT MODULE
CLS
DIM L(100)
COLOR 15
FOR F = 1 TO 23
PRINT "=";
NEXT F
PRINT
PRINT "SELECTION SORT MODULE"
FOR F = 1 TO 23
PRINT "=";
NEXT F
PRINT
PRINT
Input "How many inputs :",a
for i = 1 To a
print "Item #";i;
input L(i)
next i
Let N = I - 1
FOR I = 1 TO N - 1
FOR J = I + 1 TO N
IF L(J) >= L(I) THEN 330
LET Q = L(J)
LET L(J)=L(I)
LET L(I) = Q
330 NEXT J
NEXT I
PRINT
PRINT " Sorted List of";a; "items"
PRINT
For I = 1 To N
PRINT L(i)" ";
NEXT I
delay 3
cls
GOTO 100
END

510
REM QUICKSORT MODULE
CLS
Dim S(100)
COLOR 15
FOR F = 1 TO 22
PRINT "=";
NEXT F
PRINT
PRINT TAB(3) "QUICKSORT MODULE"
FOR F = 1 TO 22
PRINT "=";
NEXT F
PRINT
PRINT

PRINT "How many inputs :";
INPUT V
for R = 1 To V
print "Item #";R;
INPUT S(R)
next R
for O = 1 TO V - 1
FOR I = O + 1 TO V
IF  S(I) >=  S(O) THEN 130
LET C = S(O)
LET S(O) = S(I)
LET S(I) = C
130 NEXT I
    NEXT O
PRINT
PRINT " Sorted List of";V "items"
PRINT
FOR F = 1 TO V
PRINT S(F);
NEXT F
delay 3
cls
GOTO 100
END

610
REM MERGESORT MODULE
CLS
DIM X(100)
COLOR 15
FOR F = 1 TO 20
PRINT "=";
NEXT F
PRINT
PRINT " MERGESORT MODULE"
FOR F = 1 TO 20
PRINT "=";
NEXT F
PRINT
PRINT
Input "How many inputs :",a
for i = 1 To A
PRINT "Item #";i;
INPUT X(i)
next i
LET N = I - 1
For J = 1 To N - 1
For I = 1 To N-J
If X(i) <= X(i+1) then 970
Let T=X(I)
LET X(i)=X(i+1)
LET X(i+1)=T
970 Next I
Next J
PRINT
PRINT " Sorted List of";a; "items"
PRINT
For I = 1 To N
PRINT X(I)" ";
NEXT I
DELAY 3
CLS
GOTO 100
END

1000 END



No comments:

Post a Comment