The following simple programs illustrate QBASIC syntax for simple processes. Using QBASIC enter and run each of the following programs. Try to determine how the output was produced from the program commands.

- First run the QBASIC integrated programming environment.

- Enter and run each of the programs below.

- To print out a program click on
**File**followed by**Print**. Then < >**Current Module**, then**<OK>**

- To print out the output of the RUN press <Print Screen> or if
in Windows <Shift><Print Screen>

- To print out a graphics screen, it is best not to be in Windows, go
to your Disk A: or B: and type
**Graphics**, then run QBASIC and your program.

- Prog 1: Type in the following program
- Run it 3 times using different values for the radius.
`SCREEN 9`

INPUT "Radius"; radius CIRCLE (200, 200), radius, 2 ' 2 is color green

LINE (100, 100)-(100 + radius, 100 + radius), 3, B ' 3 is blue - Describe what happens and why?
- Print out program and RUNs.
- Prog 2 : Finding Prime Numbers
- Enter the following Program
`CLS`

INPUT "Type in an integer number greater than 2 ", N

LPRINT "Your number is "; N A$ = "YES"

FOR Test = 2 TO SQR(N)

IF INT(N / Test) = N / Test THEN A$ = "NO": PRINT "Divisor:"; Test

NEXT Test

PRINT "This is a PRIME number?.. "; A$ _ - Run the program for a few sample numbers.
- Are the following number are PRIME: 1101, 1001, 1111, 123, 321,123 001.
- Find three new PRIME numbers greater than 100 000.
_______________ ___________________ ______________

- Print a listing of the program and the run for the following numbers
2000 and 3001.

- Prog 3 : Simulation of Coin Flips This article is translated to Serbo-Croatian language by Jovana Milutinovich at WebHostingGeeks.com.
- Type in the program
`RANDOMIZE TIMER`

INPUT "How many flips"; Num

PRINT "Number of flips "; Num

Heads = 0

FOR Flip = 1 TO Num

IF RND > .5 THEN Heads = Heads + 1

NEXT Flip

PRINT "Percent of Heads = "; Heads / Num * 100; "%" - Run the program and print out each run for 10, 100, 1000, 10 000 flips..
- What do you notice about the percentage of Heads?
- What is the theoretical % of Heads? Write out answer on the printouts!!
- Change PRINT statement to LPRINT in each line of the program
**Analysis of Cion Flipping :**- Run the program for 10 000 flips.
- Then run the program again for as many HEADS as your last run.
- Repeat this process until there are 59 or less HEAD's

- A Sample of the runs are given below:
How many flips? 10 000

# of Heads = 5060How many flips? 5060

# of Heads = 2549How many flips? 2549

# of Heads = 1257How many flips? 1257

# of Heads = 629How many flips? 629

# of Heads = 298How many flips? 298

# of Heads = 143 - After you have run the program, put the data in table form. Illustrated
below :
Trial #

Num Heads

1

10000

2

5060

3

2549

4

1257

5

629

6

298

7

143

- Use the CORCO program with this data to determine which mathematical function could generate this data.
- You are THE DETECTIVE use CORCO to determine what type of mathematical function best fits the data. Is it a Straight Line, Exponential, or Power?
- Here is a sample of what your graph in CORCO would look like.
- For the best curve fit choose the function with the value of R closest to 1. Type _________
- Print out a graph of the best Corco fit.
- Write out the best fit function on the printout and comment on the correlation coefficient!
- Prog 4 : Grpahics
- Enter the following program
`RANDOMIZE TIMER`

SCREEN 12

FOR Picture = 1 TO 50

X = 30 + RND * 550

Y = 30 + RND * 300

Radius = RND * 50

Color1 = RND * 12

Color2 = RND * 12

CIRCLE (X, Y), Radius, Color1

CIRCLE (X, Y), Radius + 1, Color1

PAINT (X, Y), Color2, Color1

NEXT Picture - Describe what you see when you run the program 3 different times.
- Print out a listing of the program and one of the graphics.
- Make the following changes and run the modified program:
`RANDOMIZE TIMER`

SCREEN

FOR Pic = 1 TO 500

X = 30 + RND * 550

Y = 30 + RND * 300

Radius = RND * 100

COLOR1 = RND * 12

COLOR2 = RND * 12

LINE (X, Y)-(X + Radius, Y + Radius), COLOR1, B

LINE (X, Y)-(X + Radius + 1, Y + Radius + 1), COLOR1, B

PAINT (X + 2, Y + 2), COLOR2, COLOR1

NEXT Pic - Describe what you see when you run the program 3 times.
- Print out a listing of the program and one of the graphics.