Qbasic Program To Sort Numbers
Works with: QBasic. Number Reversal Game Task from Rosetta Code Wiki::Batch File Implementation. Sort the numbers in ascending order by repeatedly. Over the following summer I wrote a program on paper that found and printed out the nth prime number. Once I started the QuickBASIC class and again had access to a computer that I could use to write QuickBASIC programs, this is the program that resulted. Later I ported it to the TI-BASIC language on the TI-83 I used through high school. The only output necessary for this program is the median value. Using the sorting program we developed this chapter, change it so that the numbers generated range between 1 and 1000. Change the original sorting program so that it generates 150 items. Change the original sorting program so that the list is sorted in descending order. I think it would not be that long - on a single run - especially because arrays in QBasic limited to 32000 something elements. There could be things there you need it fast. Like, multiple sorting (say, to keep some array sorted after insertion/deletion.) And you better know that there is a faster way. And it's nice to have it handy. To clarify the EDSAC program, an equivalent Pascal program is added as a comment. Bubble sort demo for Rosetta Code website EDSAC program. Game genie for sega genesis. Initial Orders 2 Sorts a list of double-word integers. List must be loaded at an even address. First item gives number of items to follow. Address of list is placed in location 49. The name must not start with a number or character that is not a letter. Also, the name of the variable must not be a reserved name like PRINT, INPUT, LET, ABS, BEEP, etc. There are two ways to declare a variable in QBasic / QB64.
That?s an overview of what the program does, however I am stuck on one particular part and was hoping I can get some help here. I have everything working in the program as I want, except the sorting alphabetically section. To me it looks like the logic is correct in B020SortArray, however when the program prints the list of sorted names their not sorted alphabetically. Here is the program logic if anyone would be willing to help me out:
I am also wondering if there is a more efficient way to do this(found in B020SortArray):
Code: Select all
Thanks in advance for any help.Qbasic Program To Sort Numbers Printable
QBasic Tutorial 4 - Variables and Data Types - QB64
Qbasic Program To Sort Numbers Worksheet
Data Types in QBasic / QB64
The computer can hold data in memory. The programmer must tell the computer what type of data to hold. This is called a data type.
String...Text and characters
Example: This line is an example of a string
Integer..Non-floating-point numbers from -32,768 to 32,767
Examples: 67, -34, -100, 203, 1022, -1, 0
Long...Non-floating-point numbers from -2,147,483,648 to 2,147,483,647
Examples: 560005, 3, -2, 0, -867000, 14, 8, -10
Single..Floating-point numbers from -3.37x10^38 to 3.37x10^38
Examples: 4.3, 25.4567, -35.87, 0.35, -3.14
Double..Floating-point numbers from -1.67x10^308 to 1.67x10^308
Examples: 745663.90596, -98.12, 4859903.094491
Note: In QBasic 1.1, the Double may not work properly on some computers.
64 Bit Data Types (QB64 Only)
_INTEGER64 -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
_FLOAT ±1.18E−4932, ±1.18E+4932
List of QB64 Data Types
qb64.net/wiki/index.php?title=Data_types
Variables
• Hold data in memory
• Are assigned a data type
• The data can change throughout the program’s operation
• The data entered must be the same data type as assigned to the variable
A variable name is a name that is given to the data. The name must not start with a number or character that is not a letter. Also, the name of the variable must not be a reserved name like PRINT, INPUT, LET, ABS, BEEP, etc.
There are two ways to declare a variable in QBasic / QB64.
The first is to put a data type symbol after the name
$ String
% Integer
& Long
! Single
# Double
&& _INTEGER64 (QB64 Only)
## _FLOAT
Examples
MyName$
Num1%
Num2!
Answer!
The second way is the preferred way since Visual Basic uses this method. Download omniplan for mac free. Becoming accustom to this way will help the transition from QBasic / QB64 to Visual Basic. DIM is used to make variables of a data type.
DIM [Variable Name] As Data Type
DIM [Variable Name] AS STRING
DIM [Variable Name] AS INTEGER
DIM [Variable Name] AS LONG
DIM [Variable Name] AS SINGLE
DIM [Variable Name] AS DOUBLE
DIM [Variable Name] AS _INTEGER64
DIM [Variable Name] AS _FLOAT
Examples:
DIM MyName AS STRING
DIM Num1 AS INTEGER
DIM Num2 AS SINGLE
DIM Answer AS Double
Remember that selecting the right data type for the variable is very important to make the program operate properly.
Code Download
QBT4_1.BAS
QBT4_2.BAS