 Home ACAD Computer Studies Graphical Knot Making Photoshop Sudoku

# Programming sequence

• To see how programming works we must first consider what a program is:
• A program is a list of instructions that a computer must follow in order to process data in information.
• To design a good program one must follow the following steps:

1. Clarify the programming needs
o Clarify objectives and users o Clarify desired outputs o Clarify desired inputs o Clarify the desired processing
2. Design the program
o Determine the program logic o Design details using flowcharts or other means o Do a structured walkthrough
3. Code the program
o Select an appropriate programming language (basic – pascal – c – etc..) o Follow the syntax (mind the correct commands)
4. Test the program
o Perform a disk-check (proof reading .. simply reading through) o Debug the program (fix syntax and logic errors) o Input real data and check the output
5. Document and maintain the program
o Prepare user documentation (how to use the program) o Prepare operator documentation (how to fix minor problems when the program crashes for system administrators) o Prepare program documentation (how to maintain the program for new programmers) o Maintain the program (make necessary changes and keep the data up to date)

Write the following programs written down below.

Program 1 SCREEN 13 FOR x = 0 TO 319 FOR y = 0 TO 199 PSET (x, y), (COS(x / 10) + SIN((y + x) / 10) + 2) * 63 NEXT y NEXT x FOR i = 0 TO 255 PALETTE i, INT(i / 4) NEXT i

Program 2 SCREEN 13 FOR x = 0 TO 319 FOR y = 0 TO 199 PSET (x, y), (COS(x / 28) + SIN((y * x) / 1720) + 2) * 63 NEXT y NEXT x FOR j = 0 TO 1 STEP .01 FOR i = 0 TO 255 PALETTE i, INT(i * j / 4) * 256 NEXT i NEXT j

Program 3 pi = ATN(1) * 4 DIM c%(360), s%(360) FOR a = 0 TO 360 ar = a / 180 * pi c%(a) = (COS(ar) + 1) * 63 s%(a) = (SIN(ar) + 1) * 63 NEXT a SCREEN 13 FOR x& = 0 TO 319 FOR y& = 0 TO 199 PSET (x&, y&), c%((x& * 4) MOD 360) + s%((y& * x& / 10) MOD 360) NEXT y& NEXT x& rouge = 32 vert = 32 bleu = 32 i = 128 DO PALETTE i, (INT(rouge * i / 255) + INT(vert * i / 255) * 256 + INT(bleu * i / 255) * 65536) i = i + .01 IF i > 255 THEN i = 0 rouge = rouge + .001 IF rouge > 63 THEN rouge = 0 vert = vert + .002 IF vert > 63 THEN vert = 0 bleu = bleu + .004 IF bleu > 63 THEN bleu = 0 LOOP UNTIL INKEY\$ <> ""

Program 4 DECLARE SUB rol (couleur!, borne!, increment!) pi = ATN(1) * 4 DIM c%(360), s%(360) FOR a = 0 TO 360 ar = a / 180 * pi c%(a) = (COS(ar) + 1) * 63 s%(a) = (SIN(ar) + 1) * 63 NEXT a SCREEN 13 FOR x& = 0 TO 319 FOR y& = 0 TO 199 PSET (x&, y&), c%((x&) MOD 360) + s%((y& * x& / 40) MOD 360) NEXT y& NEXT x& r = 32: rr = .001 v = 32: rv = .002 b = 32: rb = .004 i = 128: ri = .01 DO PALETTE i, (INT(r * i / 255) + INT(v * i / 255) * 256 + INT(b * i / 255) * 65536) rol i, 255, ri rol r, 63, rr rol v, 63, rv rol b, 63, rb LOOP UNTIL INKEY\$ <> "" SUB rol (couleur, borne, increment) IF increment > 0 THEN couleur = couleur + increment IF couleur > borne THEN couleur = borne increment = -increment END IF END IF IF increment < 0 THEN couleur = couleur + increment IF couleur < 0 THEN couleur = 0 increment = -increment END IF END IF END SUB

You can start out with these 4 simple programs and then change variables to see what happens. During this process you will get more familiar with the coding syntax and looping procedures.  