You are on page 1of 50

Computer hard wares Hard wares are physical parts of a computer system. They are tangible parts.

They are classified into input devices and output devices. Input devices are: a) Key board b) Mouse c) Scanner etc Output devices are: a) Printer b) Monitor etc Soft wares These are sets of programs that are used to tell the computer hardware what to do and how to do it. They are classified into: a) System software b) Application software c) Programming languages Types of structured programming languages. a) Pascal b) Structured c) obol d) !ortran etc History of programming languages a. Machine languages onsists of strings of digits or numbness that instructs the computer to perform a certain operation. b. Assembly language lose machine language other than human language. They are symbolic representation of machine code. c. High level language it close to human language or synta". Allows a problem to be specified in a human understandable and oriented manner. The grammer of high level language is close to human vocabulary.

d. #th generation language


%!#! &. "!&I '

PAS A$ T%T&'(A$S PR P!R " #$:

They are languages that allow the user of a program to )uery a database. The synta" of # th generation languages is natural and user friendly. %ses menus to prompt a non*specialist to retrieve data with easy. e. +th generation languages These are languages that will allow program developed to mimic and copy human characters. Most of them are still under development. ,.g. ,"pert systems and Artificial intelligence. Programming paradigms a. Procedural programming (t combines returning se)uences of statements into one program. A procedure call is used to invo-e the procedure to return one or more values. b. Modular programming The procedures of common functionalities are grouped together into separate modules. The program is then divided into several smaller modules which interact through procedure calls and form a whole program. c. %nstructured programming A programming techni)ue whereby statements in a program have a specified arrangements of statements. A global statement can be called from any part of a program. d. Structured programming Statements in a program are arranged and e"ecuted in a specified order. &ne statement after another are translated to machine code. e. &b.ect oriented programming Techni)ues where ob.ects communicate with one another while don/t -now how they are implemented. f. ,vent driven programming A techni)ue where programs written respond to events.

%!#! &. "!&I '

PAS A$ T%T&'(A$S PR P!R " #$:

g. Pseudo code This is an artificial and informal language that helps programmers to develop algorithms. Pseudo code programs are not e"ecuted in the computer. They help a programmer to thin- out a problem0program before attempting to write on a computer programming language. Assignment Computer hardware and software consideration in structured programming. a) Hardware re)uirements b) Appropriate operating system PRO(R!) " * 'OP) &T !&" " SI(& Program development The process of formulating codes in a computer program. Program development involves coding a given tas- in a programming language Program design The activity of progressing from a specification of some re)uired program to a description of the program itself. The input to this phase is a specification of what the program is re)uired to do. 1uring the phase the design decisions are made as to how the program will meet these re)uirements2 and the output of the phase is a description of the program in some form that provides a suitable basis for subse)uent Characteristics of a good Pascal program. larity 'obustness 'eliability ,fficient Program development cycle c) Problem solving phase i. ii. iii. Analysis and specification %nderstand 3define the problem and what the problem must be. 4eneral solutions3program) 1evelop a logical se)uence of steps to be used to solve the problem. 5erify !ollow the steps e"actly to see if the solution really does solve the problem.

%!#! &. "!&I '

PAS A$ T%T&'(A$S PR P!R " #$:

d)

(mplementation phase i. ii. specification solution Translate the algorithm into a programming language 3code). Test Have the computer follow instructions and then chec- the results. (f you find errors2 analy6e the program and the algorithm to determine their source and then ma-e corrections.

e)

Maintenance phase i. ii. %se the program. $et users use the program and see if it meets it needs. Maintain Modify the program to meet changing needs from end*users2 or correct any routine errors that may show up in using it.

Program design tools a+ ,low chart A flow chart is a graphical method of designing programs. A well*drawn flow chart is also very easy to read since it basically uses .ust two symbols2 two decision constructs and two iteration constructs.

%!#! &. "!&I '

PAS A$ T%T&'(A$S PR P!R " #$:

,low chart sym-ols &val * The start symbol. Start

The diamond * The decision symbol.

Decision

'ectangle * The input symbol. Input/process

Parallelogram 3'hombus) 7 output. Output

The oval 7 stop symbols

Stop The $ine * connector

.ample onstruct a flow chart that can be used to get the sum of two numbers.
%!#! &. "!&I '

PAS A$ T%T&'(A$S PR P!R " #$:

Start

Enter values x and y

Sum = x + y

Sum

Stop Some rules for flow charts a) ,very flow chart has a STA'T symbol and a ST&P symbol b) The flow of se)uence is generally from the top of the page to the bottom of the page. c) %se arrow*heads on connectors where flow direction may not be obvious. d) There is only one flow chart per page e) A page should have a page number and a title f) A flow chart on one page should not brea- and .ump to another page g) A flow chart should have no more than around 8+ symbols 3not including STA'T and ST&P) -+ Pseudo code

This is an artificial and informal language that helps programmers to develop algorithms. Pseudo code programs are not e"ecuted in the computer. They help a programmer to thin- out a problem0program before attempting to write on a computer programming language. Pseudo* ode is simply a numbered list of instructions to perform some tas-.

c+

!lgorithms

This is a step by step process of solving a problem by e"ecuting a series of actions in a specific order. A procedure of solving a problem in terms of actions to be e"ecuted and the order in which
%!#! &. "!&I '

PAS A$ T%T&'(A$S PR P!R " #$:

they are to be e"ecuted. Algorithm is also an ordered sequence of unambiguous and well-defined instructions that performs some task and halts in finite time a) An ordered se)uence means that you can number the steps b) %nambiguous and well*defined instructions means that each instruction is clear2 do*able2 and can be done without difficulty c) Performs some tas- halts in finite time 3algorithms terminate9) .ample / Computing Sales Ta. of sugar in ,atuma0s shop !atuma sales sugar in her shop. The government re)uires her to pay sales ta" after each sale. 1esign a Pseudo*code that computes the final price of the sugar after ta" has been deducted. :ote the three types of instructions; input 3get)2 process0calculate 3<) and output 3display). Solution 8. 4et price of item =. 4et sales ta" rate >. Sales ta" < price of time times sales ta" rate # !inal prince < price of item plus sales ta" +. 1isplay final price ?. Halt .ample 1 Compute wee2ly wages of the wor2ers in %isii coffee ,arm. The pay rate for each wor-er is Kshs.8@@ per hour for A hours normal hours. The pay rate for overtime is Kshs.=@@ per hour. 1esign a Pseudo*code for the tas- of computing gross pay given pay rate and hours wor-ed. 8. 4et hours wor-ed =. 4et pay rate >. (f hours wor-ed less than or e)ual to A hours then #. 4ross pay < pay rate times hours wor-ed +. ,lse ? 4ross pay < pay rate times hours wor-ed plus overtime hours times overtime pay rate B. 1isplay gross pay A. Halt d+ "ecision ta-les A decision table is a tabular form that presents a set of conditions and their corresponding actions.
%!#! &. "!&I '

PAS A$ T%T&'(A$S PR P!R " #$:

Condition Stu-s ondition stubs describe the conditions or factors that will affect the decision or policy. They are listed in the upper section of the decision table. !ction Stu-s Action stubs describe2 in the form of statements2 the possible policy actions or decisions. They are listed in the lower section of the decision table. Rules 'ules describe which actions are to be ta-en under a specific combination of conditions. They are specified by first inserting different combinations of condition attribute values and then putting CDs in the appropriate columns of the action section of the table. "ecision Ta-le )ethodology 8. (dentify onditions E !ind the data attribute each condition tests and all of the attributeDs 5alues values. =. ompute Ma" :umber of Multiply the number of values for each condition data attribute by 'ules each other. 1etermine each independent action to be ta-en for the decision or >. (dentify Possible Actions policy. !ill in the values of the condition data attributes in each numbered #. ,nter All Possible 'ules rule column. +. 1efine Actions for each !or each rule2 mar- the appropriate actions with an C in the decision 'ule table. ?. 5erify the Policy 'eview completed decision table with end*users. B. Simplify the Table ,liminate and0or consolidate rules to reduce the number of columns. .ample A mar-eting company wishes to construct a decision table to decide how to treat clients according to three characteristics; 4ender2 ity 1weller2 and Age group; A under >@2 F between >@ and ?@2 over ?@. The company has four products G2 C2 H and I to test mar-et. Product G will appeal to female city dwellers. Product C will appeal to young females. Product H will appeal to Male middle aged shoppers who do not live in cities. Product I will appeal to all but older females. /. Identify Conditions 3 *alues The three data attributes tested by the conditions in this problem are gender2 with values M and !J city dweller2 with value H and :J and age group2 with values A2 F2 and as stated in the )uestion. 1. Compute )a.imum &um-er of Rules The ma"imum number of rules is = " = " > < 8= 4. Identify Possi-le !ctions The four actions are; mar-et product G2 mar-et product C2 mar-et product H2 mar-et product I.
%!#! &. "!&I '

PAS A$ T%T&'(A$S PR P!R " #$:

5. nter !ll Possi-le Rules The top of the table would loo- as follows; :ote that all combinations of values are present. The format6structure of a Pascal Program A structure is the order in which programs statement in Pascal must follow. Felow is the basic structure that every Pascal program must follow. &ptional comments omments address solely the readers of a program. They provide an overview of a program or one of its components. They also supply the e"tra information about why a program was constructed. omments are enclosed in curly brac-ets KL. omments appear anywhere in the program other within a string constant. Header The header identifies the program and is terminated by a semicolon. The header must ahave the name of the program. And the specification on how to this program interacts with the e"ternal data. ,.g. Program sum 7input8 output+9 1eclarations 1escribes and identifies the ob.ects used by the program. ,.g. *ar .8 y8 :: integer9 1eclarations can be e"tensive in programs that are larger or more sophicated. 1eclarations show and specify the variables used by the program. (t also specifies the dataytypes and constants. Fody of the program Specifies the actions to be ta-en when the program e"ecutes. onsists of a se)uence of statements separated the semicolons between -eywords # (I& and &". Statements specify individual steps in computation. A period following the -eyword &" mar-s the end a program.

PRO(R!) Program:ame9 #loc2 *!R declaration 5ariable:ame; 5ariable dataTypeJ 5ariable:ame; 5ariable dataTypeJ onstants Type definitions
%!#! &. "!&I '

PAS A$ T%T&'(A$S PR P!R " #$:

Procedures and functions Statement3s)J &". Program elements Pascal synta. and semantics A programming language is a set of rules2 symbols2 and special words used to construct a program. There are rules for both synta" 3grammar) and grammar 3meaning). Synta" refers to rules governing how valid instructions 3constructs) are written in a programming language. Semantics refers to a set of rules that determine the meaning of instructions 3constructs) written in a programming language. Synta" defines e"actly what combinations of letters2 numbers and symbols can be used in a programming language. Identifiers (dentifiers name things. (t is a name associated with a process or ob.ects and is used to refer to that process or ob.ect. Rules of using identifiers Must start with a letter They must have a meaning an have both uppercase and lowercase %eywords in Pascal They are reserved words that are used to develop programs. ,"amples And 1o !unction Program ase Type etc Operators in Pascal An operator is a symbol that is used in a formula to carry out a calculation to get the result. Types of operators )athematical operators %sed to carry out arithmetic functions Plus 3M) Subtraction 3*) 1ivision 30) Multiplication 3N) Modulus 3Mod) aret 3O) $ogical operators %se to compare two or more values in a program to return value.
10
PAS A$ T%T&'(A$S PR P!R " #$:

%!#! &. "!&I '

< P Q P< Q< PQ 'elational operators %sed to compare and relate two or more items in a program. A:1 &' F,TG,,: (: $(K,

1ata Types The dataType specifies the -ind of data stored by the variable declared. Ge have two categories of dataType in Pascal; Fuilt in dataType %ser defined datatype There are five built in datatype in Pascal; I&T ( R8 R !'8 CH!R8 #OO' !& 2 and STRI&(. I&T ( R A pos t ve or ne!at ve "#ole num$ers $et"een a smallest %ne!at ve& and a lar!est num$er' (n !eneral t#e smallest and lar!est num$er poss $le depends on t#e ma)# ne smallest Integer: *>=B?? largest Integer: >=B?B Are decimal numbers. They have an integer part and a fractional part. an contain a real number in scientific or decimal notation. There is a limit on the si6e and accuracy of the real number that will be covered later. 5alid real numbers are2 for e"ample; "ecimal &otation: 8.=># or *>#.++@B Scientific &otation: +.@,*> or *B.##>,> 1escribes the data consisting of one alphanumeric character such as letter2 a digit or special symbol such as Ra/2/A/2/AS

R !'

CH!R

#OO' ! Has only two parts3values) true or false. & STRI&( A string is a collection of up to =++ characters enclosed in single )uotes. !or e"ample; DFertD is a string of # characters.

%!#! &. "!&I '

11

PAS A$ T%T&'(A$S PR P!R " #$:

.pressions and assignments An e"pression is a collection of operands .oined together to perform an operation and return a value. Assignment is e)uating a variable to a value in an e"pression. ,.g. Sum;< "MyM6J !ssignments for students 1escribe the following datatype; Simple dataType Structured datatype Program writing in Pascal .ample / Grite a program that calculates the sum of three numbers Solution Program add3input2 output)J 5ar "2 y2 62sum;integerJ Fegin Griteln3Renter the value of "2y26/)J 'eadln3"2y26)J Sum;<"MyM6J Griteln3RThe sum is/2sum)/ ,nd. .ample 1 Grite a program that calculates the area of a circle given Pi <>.8#=. Solution Program circle3input2output)J onst pi; <>.8#=J 5ar radius;realJ 5ar area;realJ Fegin Grteln3R,nter the radius of a circle/)J 'eadln3radius)J Area;<piNradiusO=J Griteln3RThe area of the circle is/2area)J ,nd. Pascal varia-les
%!#! &. "!&I '

12

PAS A$ T%T&'(A$S PR P!R " #$:

These are identifiers whose values change during e"ecution. Pascal constants These are items that don/t change during e"ecution. Program Input6Output statements

The input data items must be placed in a separate file called input file before the corresponding is run. The output data are transferred from the computer memory to output file. The data items are stored se)uentially in the order they were stored or written. the items will then be grouped into logical lines which will be then correspond to physical lines of output when data ( printed or displayed. ,.g. Program payroll7input8output+9 'ead statement %sed to read data items from input file and assign them to an integer2 real2 char and Foolean type variables. e.g Read7.8y8:+9 Readln statement %sed to read data items from input file and assign them to an integer2 real2 char and Foolean type variables. e.g Readln7a8-8c+9 The difference between the 'eadln and read is that the 'eadln causes the ne"t 'ead or 'eadln statement to begin by reading a new line of data. The read statement allows the ne"t read or 'eadln to begin on the same line.

;rite statement %sed to write data items to an output file. ;rite7<The sum is <8sum+9 ;rite7<=080=0+9

;riteln statement (dentical to write e"cept that the Griteln statements results in and of linedesignation being written after the last data item.

%!#! &. "!&I '

13

PAS A$ T%T&'(A$S PR P!R " #$:

;riteln7<The area is08area+9 Program compiling This involves a process of testing a program in structured programming to chec- if the program is error free. (t is a process of converting a program from course code to its ob.ect e)uivalent. Program de-ugging This is a process of correcting errors in a program. Ghen a program e"ecutes in structured programming2 it must produce the e"pected results. (f it doesn/t give the e"pected output then it has errors. (n this regard the programmers should start the process of debugging. Testing programs in structured programming This is a process of running 3e"ecuting) programs to find errors 3bugs). The process of finding bugs is called debugging as mentioned above. Program testing is part of the procedure which ensures that the program corresponds with original program specification and that it wor-s in the intended environment. Test plan These are the stages involved in testing the programs. They include the following. 8. 1es-chec-ing After writing the program the programmer goes through the program on a paper to eliminate any error that might cause e"tra wor- later. =. Translator system chec-ing After coding the program is chec-ed using the compiler or translator to detect any synta" error. The programmer corrects these errors and then resubmits the program to the compiler until the errors are over. >. Program run with test data These re trial runs done with test data that includes all variations and e"tremes data including data with errors to ensure that program does not grind to an halt if incorrect data is used. #. 1iagnostic procedures !or comple" programs diagnostic procedures are used to find logical errors. A trace routine print the results at each stage to enable errors detected )uic-ly. (f the trace routine is not available2 the programmer can insert instructions in the program to print out intermediate results at -ey points.
%!#! &. "!&I '

14

PAS A$ T%T&'(A$S PR P!R " #$:

+. System test with actual data 3full*scale) system %sually new systems are run parallel with e"isting system for a short period so that the results are compared and ad.ustments made. Test data This is the information that is used to test the new system or program. The program tried and e"ecuted at least once every routine through the program and the accuracy of the program is verified to meet the original design specification. Categories of test data "ummy data This is the data input into a system for trial purposes. %sed to test the system for correctness. Real data 7normal data+ This includes the general data for which the system was designed. .ceptional data Programs are designed to accept certain range of data. (f illegal data is input it should be able to detect and re.ect it rather than try to process it to avoid getting wrong results. Types of errors structured programming 'ogical errors This is a human error. A programming mista-e that ma-es a program code to output wrong results. Synta. error These are an error that violates rules and regulations or the synta" of a language. Runtime error These are the undiscovered error in a program. STR>CT>R " PRO(R!))I&( CO&TRO' STR>CT>R S The operators Symbols used to calculate some value and return results. Arithmetic operators
15
PAS A$ T%T&'(A$S PR P!R " #$:

%!#! &. "!&I '

%sed to perform mathematical operations. Plus 3M) Multiplication 3N) Subtraction 3*) 1ivision 30) Modulus 3mod) $ogical operators P Q Q< P< PQ 'elational operators And &r Fetween :ot ontrol structures are classified into three; Selection control structures The user is given options to choose from among the alternatives. (teration control structures The statements repeat themselves until the condition is met. se)uence control structures The programs are e"ecuted in a specified order.

The ;hile?"o statement This is an iterative control structure that is used to carry out the conditional looping. The loop will be e"ecuted so long as the Foolean e"pression remains true. (t e"ecutes the condition to test their falsity. .ample / %sing the Ghile*1o statement write a program that prints 8@ digits on the screen. Program number 3input2 output)J 5ar ";integerJ
%!#! &. "!&I '

16

PAS A$ T%T&'(A$S PR P!R " #$:

begin C;<8J Ghile "P<8@ do Fegin C;<"M8J Griteln3")J ,ndJ ,nd. .ample 1 Grite a program using GH($,*1& iterative control structures that prints two numbers and gets their sum. Program numbers3input2 output)J 5ar ";integerJ 5ar sum;integerJ Fegin ";<8J Sum;<@J Ghile "P<= do begin ";<"M8J Sum;<"MsumJ Griteln3sum)J ,ndJ ,nd. .ample 4 Grite a program using GH($,*1& iterative control structures that prints si" numbers and gets their average. Program numbers3input2 output)J 5ar ";integerJ 5ar sum;integerJ Average;realJ Fegin ";<8J Sum;<@J Ghile "P<? do begin ";<"M8J Sum;<"MsumJ Average;<sum0?J Grteln3average)J ,ndJ ,nd.

%!#! &. "!&I '

17

PAS A$ T%T&'(A$S PR P!R " #$:

!alse $oop *ond t o n True Statements

a+ Repeat until control structure The repeat condition e"ecutes a Statement first. After the first e"ecution of the Statement2 it e"amines the ondition. (f the ondition is true2 then it e"ecutes the Statement again. (t will -eep e"ecuting the Statement !S 'O&( !S the ondition is true. &nce the ondition becomes false2 the looping 3the e"ecution of the Statement) would stop. 'epeats a se)uence of statements repeatedly until a Foolean e"pression becomes false. The se)uence of statements will be e"ecuted at*least once since the Foolean e"pression is not tested until the end of the control structure. The Statement of a repeatTuntil condition can span as many lines as necessary. (n this case2 although you can2 you do not have to start the Statement with the begin -eyword and then end it with the end -eyword. .ample / Grite a program using ',P,ATT..%:T($ iterative control structures that prints two numbers and gets their sum. Program numbers3input2 output)J 5ar ";integerJ 5ar sum;integerJ Fegin ";<8J
%!#! &. "!&I '

18

PAS A$ T%T&'(A$S PR P!R " #$:

Sum;<@J 'epeat ";<"M8J Grteln3sum)J %ntil "P<8@ Sum;<"MsumJ ,nd. Repeat@@@until loop flow chart Start

!alse Statements

Boolean expression

True

-+ The for Statement The for statement is typically used to count a number of items. The count can perform in incremental values or in decremental values. ,or loop Synta.: For Counter: = InitialValue to FinalValue do Statement(s ! "nd! %sing this formula2 you can count values from a stating value to an end. To do this2 you must first declare a variable that would hold the count. (n our synta"2 such a variable would be the ounter parameter. The (nitial5alue is a value assigned to the ounter variable as the
%!#! &. "!&I '

19

PAS A$ T%T&'(A$S PR P!R " #$:

starting value. The to -eyword is re)uired to proceed with the counting. The counting would stop with the value of the !inal5alue parameter. The value of (nitial5alue should be lower than that of !inal5alue. The do -eyword is re)uired and used to introduce the Statement. After one count2 the for loop would e"ecute the Statement. After e"ecuting the Statement2 the loop would checwhether the count has reached !inal5alue. (f it has not2 then the (nitial5alue would be incremented by 8 and the Statement would be e"ecuted again. This chec-ing *Q incrementing *Q Statement e"ecuting would continue until a new incremented value of (nitial5alue is e)ual to the value of !inal5alueJ in which case the loop would stop. .ample / Program e"ample=3input2 output)J var :umber; (ntegerJ sum;integerJ begin for :umber ;< @ to 8+ do sum;<"MsumJ Griteln3sum)J Grite3 hr38@)2 DPress any -ey to continue...D)J 'eadlnJ end. Start .ample 1 Program e"ample>3input2 output)J var :umber; (ntegerJ sum;integerJ average;realJ begin for :umber ;< @ to 8+ do x=1 to 10 sum;<"MsumJ average;<sum08@J Griteln3average)J Grite3 hr38@)2 DPress any -ey to continue...D)J 'eadlnJ end. Statements

(n)rement operator True

%!#! &. "!&I '

20

PAS A$ T%T&'(A$S PR P!R " #$:

$oop !alse

Selection6Conditional control structures onditional control structures allow action to be ta-en if the given logical condition has a specified value either true or false. If control structure A conditional control structure that allow some action to be ta-en if the given logical condition has a specified value either true or false. The statements wil be e"ecuted only if the Foolean e"pression is true. (f the Foolean e"pression is false the program ignores the line. .ample / program e"ample=3input2 output)J var Age ; integerJ begin Grite3Dplease enter your age; D)J
%!#! &. "!&I '

21

PAS A$ T%T&'(A$S PR P!R " #$:

'eadln3age)J (f ageQ<8A then Griteln3RHou are an adult/)J (f age P8A then Griteln3RHou are young/)J ,nd. If@then@..else control structure %se to give options incase the predecessor does not meet the criteria given. The if condition is used to chec- one possibility and ignore anything else. (n this case2 you can use more than one if statement. ,"ample 8 Program e"ample83input2output)J %ses crtJ 5ar input;stringJ Fegin lrscrJ Griteln3R,nter the password/)J 'eadln3input)J (f3input</pascal/) then Griteln3Rpascal is the easiest structured language to learn999999999999999999/)J (f3input</basic/) then begin Griteln3Rbasic is not very hard to hard/)J ,ndJ (f3input</@/ then Griteln3Rwrong password/)J ,nd. .ample 1 Program e"ample=3input2output)J %S,S 'TJ 5ar maths2english2-iswa;integerJ 5ar sum;integerJ 5ar average;realJ Fegin lrscrJ Griteln3Renter your mar-s/)J 'eadln3maths2,nglish2-iswa)J Sum;<mathsM,nglishM-iswaJ Average;<sum0>J (f 3averageQ<A@) and 3averageP</8@@/) then Griteln3RA/)J (f3averageQ<B@) and 3averageP<BU) then Griteln3RF/)J (f 3averageQ<?@) and 3averageP<?U) then
%!#! &. "!&I '

22

PAS A$ T%T&'(A$S PR P!R " #$:

Griteln3R /)J (f 3averageQ<+@) and 3averageP<+U) then Griteln3R1/)J (f3averageQ<#@) and 3averageP<#U) then Griteln3RA/)J (f3averageQ<8) and 3averageP<>U) then Griteln3R,/)J (f 3averageQ</@/) then Griteln3RHou never sat for e"ams/)J ,nd. The case...of Statement Ghen defining an e"pression whose result would lead to a specific program e"ecution2 the case...of statement considers that result and e"ecutes a statement based on the possible outcome of that e"pression. The different outcomes are listed in the body of the case...of statement and each case has its own e"ecution2 if necessary. Case synta.; Case "#pression of Case Choice$: Statement$! Case Choice%: Statement%! Case Choice-n: Statement-n! "nd& The e"pression to e"amine can be an integer2 a character2 an enumeration type2 or a predefined list of items. .ample/ Program e"ample83input2output)J %ses crtJ var :umber; (ntegerJ Answer; harJ Fegin lrscrJ Grite3DType a number between 8 and >; D)J 'eadln3:umber)J case :umber of 8; Griteln3DHou typed 8D)J =; Griteln3DHou typed =D)J >; Griteln3DHou typed >D)J ,lse Griteln3Ryou entered an invalid numberT../)J endJ
%!#! &. "!&I '

23

PAS A$ T%T&'(A$S PR P!R " #$:

Grite3 hr38@)2 DPress any -ey to continue....................D)J 'eadlnJ end.

Introduction to Pascal su-programs Subprograms refer to any set of statements forming part of a program used to perform a specific tas-. They are instructions that are incorporated in the main program to do some tas- before passing control to the main program. A properly constructed subprogram should be self contained2 perform defined operations on well defined data and have an internal structure that is independent of the program in which its contained. Types of su-programs ,unctions A function is an assignment that must be performed to complete a program. %nli-e a procedure2 a function must return a value. A self contained program structure that can be called to do an operation and return a single value to finish e"ecution. (ts referenced by specifying the name within the e"pression as though it was an ordinary simple type variable. The function name can be be followed by one or more actual parameters enclosed in paranthesis and separated by commas Function s'nta#: Function Function(ame: )eturn*'pe! +egin
%!#! &. "!&I '

24

PAS A$ T%T&'(A$S PR P!R " #$:

"nd! !unction sum ; (ntegerJ begin 'esult ;< 8=+@ M #AJ endJ !unction Perimeter; 1oubleJ begin endJ The begin and end -eywords are re)uired because they would enclose the assignment performed by the function. Fetween the begin and end -eywords2 do whatever the function is supposed to do3instructions). After performing the assignment for function2 you must specify what value the function is returning. A function can return a either of the following;

! character:

!unction ShowSome haracter ; charJ begin 'esult ;< DIDJ endJ

!n integer;

!unction :atural ; (ntegerJ begin 'esult ;< ==AJ endJ

! floating num-er:

!unction 1ecimal:umber ; 1oubleJ begin 'esult ;< 8=.++J endJ

! #oolean value:

!unction (sMarried ; FooleanJ begin 'esult ;< trueJ endJ

! string:
25
PAS A$ T%T&'(A$S PR P!R " #$:

%!#! &. "!&I '

!unction omplete:ame; stringJ begin 'esult ;< D( showed you mine. :ow show me yoursDJ endJ ,unction call &nce a function e"ists or is -nown2 you can call it the same by simply typing its name where the function is needed. A function returns a value and this can be any values of the dataytypes2 but the value must be the type stated by the 'eturnType word. Fecause a function returns a value2 it can be passed to a Grite or a Griteln procedure to display its return value.

.ample / Program e"ample83input2 output)J !unction Addition; (ntegerJ begin addition ;< 8=+@ M #AJ endJ begin Griteln3!ddition)J end. Scope of varia-les 5ariables can be declared in function. These variables belong to the functions in which they are declared. 'ocal varia-les $ocal variables are accessed anywhere between begin and the matching end -eywords. These variables are only important inside the function.

.ample/ Program e"ample83input2 output)J 5ar "2y;integerJ !unction additionJ


%!#! &. "!&I '

26

PAS A$ T%T&'(A$S PR P!R " #$:

5ar answer;integerJ Fegin Answer;<"MyJ Griteln3RThe answer is; R2answer)J ,ndJ Fegin Griteln3RPlease enter the two numbers/)J 'eadln3"2 y)J AdditionJ ,nd. (lo-al varia-les Theses are variables declared for the entire programJ that is within the bloc- containing the function declaration. 4lobal variables can be utili6ed anywhere within the bloc- whether inside or e"ternal to the function.

.ample/ Program e"ample83input2output)J 5ar n2p2m;integerJ !unction ma"imumJ 5ar ma";integerJ Fegin (f nQp then ma";<n else ma";<pJ (f mQ ma" then ma";<m else ma";<nJ Griteln3Rthe ma"imum is; R2ma")J ,ndJ Fegin 'eadln3n2p2m)J Fegin Ma"imumJ 'eadln3n2p2m)J ,ndJ ,nd.

Procedures A self contained program structure that can be called to do an operation and return a single value to finish e"ecution. The procedures ma-e the program easy to debug2 understand and use. They also ma-e fle"ible the use of parameters.

%!#! &. "!&I '

27

PAS A$ T%T&'(A$S PR P!R " #$:

Procedure structure ,rocedure compliment +egin -riteln(.statement/ ! -riteln(.statement/ ! "nd! A procedure is referenced by its name followed by its optional parameters. .ample/ Program e"ample83input2output)J 5ar "2y26;integerJ Procedure largestJ 5ar ma";integerJ Fegin (f "Qy then ma";<" else ma";<yJ (f ";<ma" then ma";<6J Griteln3Rthe highest is; R2ma")J ,ndJ Fegin 'eadln3"2y26)J Fegin $argestJ ,ndJ ,nd. .ample/ Program e"ample=3input2 output)J 5ar "2y;integerJ Procedure addition;integerJ 5ar answer;integerJ Fegin Answer;<"MyJ Griteln3Rthe answer is; R2answer)J ,ndJ Fegin Griteln3Rplease enter the two numbers/)J 'eadln3"2y)J AdditionJ ,nd. Parameter passing

%!#! &. "!&I '

28

PAS A$ T%T&'(A$S PR P!R " #$:

Parameters are those variables that are used to hold data to be passed to the calling statement or procedure. The process of transferring these parameters is called parameter passing. Arguments are real or actual values passed to calling statement or procedure. Types of parameters ,ormal parameters These are labeled memory blan- areas that are to be used to store values to be used during e"ecution. They are identifiers rather than reserved words. !ctual parameters These are variables that replace the formal parameters when the procedure or function is called. They are given the actual parameter list of procedure call.

Classes of parameters *alue parameters %sed to to supply information to the procedure but they cannot be used to get information out of a procedure. 5alue parameter are declared by including their names and the corresponding datatypes within a procedure header without any prefi" 5A'. e.g. program parameter3input2output)J var "2y;integerJ var 62m;integerJ procedure number3";integerJy;real)J begin endJ begin number3>2"N36Mm)0yJ numner3=N3"My)2*@.+)J end. :ote; " and y are value parameter in a procedure.

*aria-le parameter %sed in applications where binformation must be transferred in both directions between the procedure and procedure reference. Ghen the procedure containing a variable parameter is accessed the actual parameter in the procedure refernce is substituted by the formal parameter within the procedure itself. !ssignment to students
%!#! &. "!&I '

29

PAS A$ T%T&'(A$S PR P!R " #$:

Procedure parameters

,unction parameters

"ata structures in structured programming These are variables that hold data two or more elements together instead of one sinle element. A tool for handling a group of logically related data items. They are user defined and provide a method for pac-ing together data of different typ@es. Classification of data structures Static data structures These are data structures which don/t change when the program e"ecutes. 1ynamic data structures. They are data structures that change when the program e"ecutes.

Types of data structures /. !rrays This is a consecutive group of memory location that all have the same name and datatype. This is a list of variables all with the same name and datatype. Ghen we wor- with a single item2 we only need to use one variable. However2 if we a list of items which are similar in type we need to declare an array of instead of using a variable for each item variables. 1eclaring arrays Arrays are declared the same way we declare normal arrays e"cept that you have to say how many elements you have in the array. e.g.
30
PAS A$ T%T&'(A$S PR P!R " #$:

%!#! &. "!&I '

5ar ";arrayV8..+W of integerJ 5ar names;arrayV8..8@W of stringJ One dimensional array7/" arrays +

This is an array that consists of one row.

.ample/ A program that prints an array of five names on the screen. Program array3input2output)J 5ar names;arrayV8..+W of stringJ 5ar ";integerJ Fegin !or ";<8 to 8@ do 'eadln3namesV"W)J Griteln3namesV"W)J ,nd. .ample 1 A program that prints an array of ten numbers on the screen. Program array3input2output)J 5ar ";arrayV8..8@W of integerJ 5ar i;integerJ Fegin !or i;<8 to + do 'eadln3"ViW)J Griteln3"ViW)J ,nd. ,"ample> A program that prints an array of ten numbers on screen and calculates their sum. Program arrays3input2output)J %ses crtJ onst students<+J 5ar numbers;arrayV8..+W of integerJ 5ar total2count;integerJ 5ar average;realJ Fegin
%!#! &. "!&I '

31

PAS A$ T%T&'(A$S PR P!R " #$:

lrscrJ Total;<@J !or count;<8 to students do 'eadln3numbersVcountW)J Griteln3numbersVcountW)J Total;<totalMnumbersVcountWJ Griteln3RThe total is R2total)J Average;<total0studentsJ Griteln3RThe average is R2average)J ,nd.

Two dimensional arrays 71" arrays+ These are arrays that have both rows and columns. 1eclaring two dimensional arrays *'pe multi = 0))01 2$&&$34 $&&$35 of integer! Var numbers:arra'2$&&65 of integer! Var names:arra'2$&&65 of integer! .ample / 4iven the following mar-s achieved in a test2 and that the pass mar- is the average of all the mar-s2 write a program to calculate the total mar-s2 average mar-s and list all those students who have passed. !',1 A::, '&F,'T , ($ X,::(!,' =8 += >> #8 4,&'4, MA'H AU B8 A$!',1 M(K, +# PA%$(:, +? B8 #A

Program e"ample83input2 output)J %ses crtJ onst noofstudents < 8@J 5ar names;arrayV8..8@W of stringJ Mar-s; arrayV8..8@W of integerJ Total2 count; integerJ Average; realJ Fegin lrscrJ
%!#! &. "!&I '

32

PAS A$ T%T&'(A$S PR P!R " #$:

nameV8W ;< D!',1 DJ mar-sV8W ;< =8J nameV=W ;< D4,&'4, DJ mar-sV=W ;< +?J nameV>W ;< DA::, DJ mar-sV>W ;< +=J nameV#W ;< DMA'H DJ mar-sV#W ;< AUJ nameV+W ;< D'&F,'T DJ mar-sV+W ;< B8J total;< @J for count;< 8 to noofstudents do total ;< total M mar-sVcountWJ writeln3DThe average mar- was D2total)J average;<total 0 noofstudentsJ writeln3DThe average mar-s is D2average)J writeln3DThe students who passed the test are D)J for count ;< 8 to ma"students do if mar-VcountW Q<+@ then writeln3nameVcountW)J writelnJ end. Trees Trees these are hierarchal data structure constructed using rule of precedence for data items using alphabetical or numerical se)uence. The elements of a tree are called nodes and each element consists of a datum and at least two pointers. +? +e,t po nter #= AU -atum ?+ #A . !#t po nter

+? is the first datum placed ( the tree. (ts node is therefore called parent node or root node. Ge add #= to the tree ne"t using rule of precedenceJ lower number to the left and higher number to the right.

Start

56

%!#! &. "!&I '

42 48 /1

33

89

PAS A$ T%T&'(A$S PR P!R " #$:

/1

/1

65

/1

A S B S E S 0 1 A S D C

E M

H Q

S K S A> > S This a chain of of data items in the computer memory awaiting e"ecution. Yueues use !(!&2 first datum in is the first datum out. haracteristics of )ueues 1ata is entered to the end but removed from the front. The term !(!& is used to describe )ueues because first datum in is the first datum out. ,ach data stays in the storage location until its turn comes thereby reducing time spent in data movement. ST!C%S They are used too temporarily store information or data. 'elated to )ueues but data is removed and added differently. 1ata is added at the top and removed from top using $(!&.

$ocation of address ontents


%!#! &. "!&I '

:e"t removal pointer 8@8 8@= 8@> 8@# =@ # 8U 8=


34

8@+ 8?

8@?

8@B

8@A

8@U

88@

PAS A$ T%T&'(A$S PR P!R " #$:

&rder of arrival &rder of removal Pointers

8 +

= #

> >

# =

+ 8

These are variables that stores memory addresses. They point to a particular address that can be used to store data items. There are two types of pointers; Typed pointers They point to variables such as integers. Typed pointers They appoint to any type of variable. Typed pointers Hou declare typed pointers using O in front of he variable type which you want to point to. The Z symbol can also be used in front of a variable to get its memory address. This memory address can be stored in a pointer because pointers store memory addresses. e.g.

program pointersJ var ";integerJ p;OintegerJ begin p;<ZiJ end. (f you change the value stored at the memory address pointed at by a pointer you must first deference the pointer variable using O after the pointer name. e.g. program pointersJ var i;integerJ var p;OintegerJ begin i;<8J p;<ZiJ pO;<=J writeln3i)J end. Hou can allocate new memory to a typed pointer using new command. The new command gets the memory that is the si6e of the variable type of the pointer and then sets the pointer to point to a
%!#! &. "!&I '

35

PAS A$ T%T&'(A$S PR P!R " #$:

memory address of it. Ghen you finish using the pointer use dispose command to free the memory that was allocated to the pointer. Program pointersJ 5ar p;OintegerJ Fegin :ew3p)J PO;<>J Griteln3pO)J 1ispose3p)J ,nd. >ntyped pointers To declare the untyped pointers you must use the variable type called pinter. To allocate memory to an untyped pointer you must use the 4etmem command instead of new command. Hou must also use !reemem command instead of dispose command to free the memory. The 4etmem command have a second parameter which is the si6e in bytes of the amount of memory which must be allocated to the pointer. Hou can either use a number for the si6e or si6efuction to get the si6e of a specific variable type. e.g. program pointersJ var p;pointerJ begin getmem3p2si6efunctionof3integer))J freemem3p2si6efunctioof3integer))J end. 'in2ed lists $ists are fle"ible ways of handling data items in order. !or e"ample; !le. -oes 2ot + 3e *a3es

,ach word in the sentence is a data item2 which is lin-ed to the ne"t data item by a pointer. 1atum plus a pointer ma-e a node or element of a list. The last item in the list is a terminator. This may be stored in an array of records. ,ach row of an array is one element in the list. A start pointer saying where the first datum is stored and a free storage pointer saying where the ne"t datum can go.

%!#! &. "!&I '

36

PAS A$ T%T&'(A$S PR P!R " #$:

'&G :& 8 = > # + ? B Start pointer

1AT%M [A$,CS [1&,SS [:&TS [$(K,S [ AK,SS

P&(:T T& TH, :,CT :& = > # + *8

&MM,:T :,CT 1AT%M :,CT 1AT%M :,CT 1AT%M :,CT 1AT%M $AST 1AT%M ,MPTH ,MPTH

!ree storage pointer

Types of lin-ed lists Single lin-ed lists The element of the record has only one pointer. Head

Address 1

Address 2

Address 3

1ouble lin-ed lists The element of the record has two pointers2 one pointer for giving the address of the following record another for giving the address of the proceeding record.

%!#! &. "!&I '

37

PAS A$ T%T&'(A$S PR P!R " #$:

Head ircular lin-ed lists The pointer of the last record gives the address first record thus this form a circular or ring of records.

Address 1

Address 2

Address 3

Introduction to Strings (n order to understand strings2 one has to -eep in mind that a string is made up of an array of characters. The string data type is an in*built data type that is an array of =+? characters 3 Type String < Pac2ed !rrayV@..=++W of Char). Ghen stored in memory2 the processor should -now where the string starts and where it finishes. (n order to -now where the string finishes2 in Pascal2 the @th element of a string is defined as the length of the string. So2 if you try to access character @ of a string2 the number of characters stored in that array is returned2 thus letting the processor to -now where the string finishes. ,"ample 8 Program e"ample83input2output) *ar myString; StringJ

%!#! &. "!&I '

38

PAS A$ T%T&'(A$S PR P!R " #$:

#egin myString ;< DHey9 How are you\DJ Griteln3DThe length of the string is D2-yte3myStringV@W))J Grite3myStringV-yte3myStringV@W)W)J Grite3D is the last character.D)J nd. ( have used an automatic data*type conversion2 normally referred to as data type-casting. Ghen type*casting from one data type to another2 all that is happening is simply a conversion from one data type to another based on the data type in sub.ect and the wrapping data type to which the old data type is being converted. (n our case2 the array variable m'String has a special @th element storing the number of characters in that array in string format. This value is an AS (( value2 so trying to display it without converting it into a numberJ the alternative AS (( character is displayed. So you have to change the character value to an ordinary number by wrapping the variable by another data type2 in our case a -yte data type 3why use integer\ * its all waste of memory and memory consumption). :ote that myStringVmyStringV@WW without having data*type casting around myStringV@W will lead to a compiler error because myStringV@W is a character and not an integer.

String ,unctions There are some basic Pascal functions that have to do with string operations. !unction Pos3SubString ; StringJ S ; String) ; FyteJ This function will search for the string SubString within the string S. (f the sub*string is not found2 then the function would return @. (f on the other hand the sub*string is found2 then the inde" integer value of the first character of the main string that matches the character of the sub*string is returned. .ample / Program e"ample83input2output)J 5ar S; StringJ Fegin S;< DHey there9 How are you\DJ Grite3DThe word ]How] is found at char inde" D)J Griteln3Pos3DHowD2S))J (f Pos3DGhyD2S) P< @ then Griteln3D]Ghy] is not found.D)J ,nd. ,unction Copy7S : String9 Inde. : Integer9 Count : Integer + : String9
39
PAS A$ T%T&'(A$S PR P!R " #$:

%!#! &. "!&I '

This function will copy some characters from string S starting from character inde" Inde# and copies as much as Count. The copied string is then returned. .ample / Program e"ample83input2output)J 5ar S ; StringJ Fegin S ;< DHey there9 How are you\DJ S ;< opy3S2 +2 ?)J K Dthere9D L Grite3S)J ,nd. Procedure "elete7var S : String9 Inde. : Integer9 Count : Integer +9

1eletes a specified number of characters from the string S. The starting position of deletion is from character inde" Index. The number of characters that will be deleted is specified through Count. The new string is passed bac- through the variable parameter S.

.ample / Program e"ample83input2 output)J 5ar S; StringJ Fegin S;< DHey Ma"9 How are you\DJ 1elete3S2 #2 #)J KRHey9 How are you\/L Grite3S)J ,nd. Procedure Insert7Source : String9 var S : String9 Inde. : Integer+9 This function will insert a string of any length into a source string starting from an inde" character. The string S will be inserted into string Source starting from the inde" character Index. :o characters will be deleted from the front e"cept if the resulting string is longer than =++ characters. (n this case2 the front characters will be truncated as to fit a =++*character string. .ample / Program e"ample83input2 output)J 5ar S; StringJ Fegin S; < DHey9 How are you\DJ
%!#! &. "!&I '

40

PAS A$ T%T&'(A$S PR P!R " #$:

(nsert3S2 D Ma"D2 #)J Grite3S)J KRHey Ma"9 How are you\/L ,nd. !unction oncat3s8 V2 s=2 s>...snW ; String) ; StringJ oncatenates = or more strings depending how long is the argument e"pression. Try to ma-e sure not to e"ceed the limit of =++ characters when concatening strings as it will result in truncation. This function can also be obtained by using the plus 3M) operator between strings that need to be concatenated.

.ample / Program e"ample83input2 output)J 5ar S82 S=; StringJ Fegin S8;< DHey9D S=;< D How are you\DJ ,nd. .ample 1 Program e"ample=3input2 output)/ 5ar S82 S=; StringJ Fegin S8;< DHey9D S=;< D How are you\DJ Grite3S8 M S=)J KRHey9 How are you\/L ,nd. ,unction >pCase7C : Char+ : Char9 onverts the character C to uppercase and returned. (f the character is already in uppercase form or the character is not within the range of the lower case alphabet2 then it is left as is. .ample / Program e"ample83input2 output)J 5ar S; StringJ
%!#! &. "!&I '

41

PAS A$ T%T&'(A$S PR P!R " #$:

5ar i; (ntegerJ Fegin S; < DHey9 How are you\DJ !or i; < 8 to length3S) do SViW;< %p ase3SViW)J Grite3S)J KRH,H9 H&G A', H&%\/L ,nd. Procedure Str35al ; (nteger 0 $ong(nt 0 'ealJ var S ; String)J onverts an integer or a decimal value to a string. The value parameter Val is converted into a string and passed through the variable parameter S.

.ample / Program e"ample83input2 output)J 5ar S; StringJ i; 'ealJ Fegin i ;< *@.+?>J Str3i2 S)J Grite3S)J ,nd. Procedure *al7S : String9 var *al9 Code : Integer+9 onverts a string to its corresponding numeric value. The string parameter S is converted into a numeric value and passed bac- through the variable parameter Val. (f the string to be converted is not a correct numeric value2 an error occurs and is returned via Code. (f the conversion is correct then ode is @. .ample / Program e"ample83input2 output)J 5ar S; StringJ ,rror; (ntegerJ '; 'ealJ Fegin S; < D*@.+?>DJ 5al3S2 '2 error)J (f ,rror Q @ then Grite3D,rror in conversion.D) ,lse
%!#! &. "!&I '

42

PAS A$ T%T&'(A$S PR P!R " #$:

Grite3')J ,nd.

,I' S H!&"'I&( I& STR>CT>R " PRO(R!))I&( A file is a collection of related records on some items of interest. !ile concepts

Fit Fyte 3Fits) haracter 3 ollection of byte) 1ata 3 ollection of characters) !ield 3 ollection of data) 'ecord 3 ollection of fields) !ile 3 ollection of related records)

%!#! &. "!&I '

43

PAS A$ T%T&'(A$S PR P!R " #$:

1atabase 3Structured collection of files)

!SSI(&) &T TO TH C'!SS ,CP$A(: TH, 5A'(&%S THP,S &! !($,S %S,1 (: Types of files There are different types of files; Master file Transaction file Fac-up file Sort file ,tc

&MP%T,'.

,I' OR(!&IB!TIO& T CH&IA> S These are the methods involved in storing files in a computer memory. O-Cectives of file organi:ation (ncrease processing speed ,asy accessibility To increase security of data !or easy references SeDuential file organi:ation !iles are arranged serially in a se)uence2 one after another. !iles are accessed in the same order they were stored. !dvantages Simple to understand and follow 'elatively ine"pensive :o gap between the records Simple to create !ast to process data. "isadvantages :o bac-up facility Mandatory sorting
%!#! &. "!&I '

44

PAS A$ T%T&'(A$S PR P!R " #$:

1ata redundancy is high $in-ing of records impossible

Random file organi:ation There is no order in the storage of files. !iles are stored randomly in the memory. !dvantages ,asy to access files ,asy and )uic- to update Sorting is not mandatory (mmediate processing "isadvantages ,"pensive :ot suitable for all storage media $ow speed 'e)uires special security measures Inde.ed seDuential file organi:ation !iles are stored se)uentially but directly accessed using an inde". !dvantages (mmediate access :o need to sort the input !le"ible ,asy to update $in-ing of records is possible "isadvantages 'e)uires additional storage space. :o bac-up facility ,"pensive ,I' " SI(& To create a file you first declare a variable of that file. After declaration you should assign the file a name using a command. To create an empty file use rewrite command. To read from an e"isting file we use reset command. %se readln to read lines of te"t from the file. Hou will also need to use while loop that repeats until it comes to the end of the file.
45
PAS A$ T%T&'(A$S PR P!R " #$:

%!#! &. "!&I '

Append command is also used to let you add more te"t to the end of the file. %se close command to close a file when you have finished using it. %ses rename command to change the file name. final you can also use erase command to erase command to delete a file.

Creating and writing to a te.t file ,"ample 8 Program te"tfile3input2 output)J 5ar !name2 t"t; stringV8@WJ %serfile;te"tJ Fegin !name;</te"tfile/J Assign3userfile2/c;^/M!nameM/.t"t/)J 'ewrite3userfile)J Griteln3userfile2/This is structured programming/)J Griteln3userfile2/(t is easy to learn and understand/)J Griteln3userfile2/(f you did not understand/)J Griteln3userfile2/Please send a mail to my inbo"/)J Griteln3userfile2/-ennyZyahoo.com/)J 'eadln3t"t)J Griteln3userfile2//)J Griteln3userfile2/the user entered this te"t/)J Griteln3userfile2t"t)J lose3userfile) ,nd. Reading from a file .ample / Program fileJ 5ar userfile; te"tJ !name; te"tfile; stringJ Fegin Griteln3R,nter the name of the file/MM3with its full path)of the te"t file;/)J 'eadln3!name)J Assign3userfile2!nameM/.te"tfile/)J 'eset3userfile)J 'epeat 'eadln3userfile2te"tfile)J
%!#! &. "!&I '

46

PAS A$ T%T&'(A$S PR P!R " #$:

Griteln3te"tfile)J %ntil ,&!3userfile)J lose3userfile)J 'eadlnJ ,nd.

Creating data files Program filesJ Type studentrecords<record :ame; stringJ Admno; integerJ 4ender; stringJ Age; integerJ ,ndJ 5ar student; te"tJ Students; studentrecordsJ Fegin Assign3student2/c;^student.t"t/)J 'ewrite3student)J Students.name;</Xohn Karani/J Students.admno;</8=>#/J Students.gender;</Male/J Students.age;<==J Griteln3Rname;<students.name/)J Griteln3Radmno;<students.admno/)J Griteln3Rgender;<students.gender/)J Griteln3Rage;<students.age/)J Griteln3students)J 'eadlnJ ,nd.

%!#! &. "!&I '

47

PAS A$ T%T&'(A$S PR P!R " #$:

PRO(R!) "OC>) &T!TIO& Program documentation describes information that helps users2 managers and people involved that must interact with the system. ,"plains the use and technical operation of the system. Importance of documentation 'educes downtime costs. Speeds maintenance costs. Supports system users Types of program documentation System documentation 1escribes system function and how they are implemented. This includes data dictionary2 flowcharts2 data flow diagrams2 ob.ect oriented models2 screen layout and source documents. &perational documentation ontains all the information needed for processing and distributing online and printed output. (t includes; system analyst2 programmer and system identification. (nput files2 scheduling information for printed output and emails and report distributing lists. %ser documentation onsists of instructions and information to the system end*users who will interact with the system. (t includes; user manuals2 help screens and tutorials. ;riting a program documentation %ser manuals The styles and formats used in user manuals include the following. Headings Mar-s he -ey contents $ists %se numbered and bulleted lists to help the user scan information )uic-ly. Special notices %se notices and warning to alert user to some potential problems. (nstructional design %se standard design of instructions. 4raphics Shows readers -ey components of the ob.ects they will be wor-ing with. Tables Provides statistical information and easy to access.

%!#! &. "!&I '

48

PAS A$ T%T&'(A$S PR P!R " #$:

Components of a user manual !ront and bac- covers Title ,dition notice Trademar-s 1isclaimers. Garranties $icence agreements Safety notice Preface Appendices 4lossary (nde"

%!#! &. "!&I '

49

PAS A$ T%T&'(A$S PR P!R " #$:

%!#! &. "!&I '

50

PAS A$ T%T&'(A$S PR P!R " #$: