Grade 11 - Educational Publications Department

Transcription

Information and CommunicationTechnologyGrade 11Educational Publications Department

First PrintSecond PrintThird PrintFourth PrintFifth Print-20152016201720182019All Rights ReservedISBN 978-955-25-0326-9Published by Educational Publications DepartmentPrinted by Saraswathi Publications,No. 2/60, Circular Road, Divulapitiya.ii

The National Anthem of Sri LankaSri Lanka MathaApa Sri Lanka Namo Namo Namo Namo MathaSundara siri barinee, surendi athi sobamana LankaDhanya dhanaya neka mal palaturu piri jaya bhoomiya ramyaApa hata sepa siri setha sadana jeewanaye mathaPiliganu mena apa bhakthi pooja Namo Namo MathaApa Sri Lanka Namo Namo Namo Namo MathaOba we apa vidyaObamaya apa sathyaOba we apa shakthiApa hada thula bhakthiOba apa alokeApage anupraneOba apa jeevana weApa mukthiya oba weNava jeevana demine, nithina apa pubudukaran mathaGnana veerya vadawamina regena yanu mana jaya bhoomi karaEka mavakage daru kela bevinaYamu yamu vee nopamaPrema vada sema bheda dureradaNamo, Namo MathaApa Sri Lanka Namo Namo Namo Namo Mathaiii

wms fjuq tl ujlf. orefjdatl ksjfiys fjfikdtl mdge;s tl reêrh fõwm lh ; ÿjkdtneúks wms fjuq fidhqre fidhqßfhdatl f,i tys jefvkdÔj;a jk wm fuu ksjfiafid k isáh hq; fõieug u fu;a lreKd . fKkSfj S iu.s oñkSrka ñKs uq; fkd j th u h iem;dlsis l, fkdu Èrkdwdkkao iurfldakaJ uõ UPÒ õ õ Áõ Jß Ó õ ÁõÊ CÀ» ß Ó Eh¼À Kk Jß Ó S v {Ó AuÚõÀ \ Põuµº õ õ Áõ JßÓõ ÁõÊ ÁÍ õ ßÓõ CÆ CÀ¼Û » » ÁõÌuÀ Ásk ß Óõ õÁ Aß P øn²hßJØÖø ]ÓUP ÁõÌ vkuÀö õßÝ o² zx À» & Ax Á õßÖ È õa ö\ÀÁ ß Óõ.BÚ u \ µU PõßPÂøu ß ö º .iv

v

ForewordThe educational objectives of the contemporary world are becoming morecomplex along with the economic, social, cultural and technological development.The learning and teaching process too is changing in relation to humanexperiences, technological differences, research and new indices. Therefore, itis required to produce the textbook by including subject related informationaccording to the objectives in the syllabus in order to maintain the teaching processby organizing learning experiences that suit to the learner needs. The textbook isnot merely a learning tool for the learner. It is a blessing that contributes to obtaina higher education along with a development of conduct and attitudes, to developvalues and to obtain learning experiences.The government in its realization of the concept of free education has offeredyou all the textbooks from grades 1-11. I would like to remind you that you shouldmake the maximum use of these textbooks and protect them well. I sincerely hopethat this textbook would assist you to obtain the expertise to become a virtuouscitizen with a complete personality who would be a valuable asset to the country.I would like to bestow my sincere thanks on the members of the editorialand writer boards as well as on the staff of the Educational Publications Departmentwho have strived to offer this textbook to you.W. M. Jayantha Wickramanayaka,Commissioner General of Educational Publications,Educational Publications Department,Isurupaya,Battaramulla.2019.04.10vi

Monitoring and SupervisionW. M. Jayantha WickramanayakaCommissioner General of Educational PublicationsEducational Publications DepartmentDirectionW. A. Nirmala PiyaseeliCommissioner (Development)Educational Publications DepartmentCo-ordinationDakshina KasturiarachchiAssistant CommissionerEducational Publications DepartmentEditorial BoardProfessor Sanath JayasenaAssociate Professor, Department of ComputerScience and Engineering, University of Moratuwa,Katubedda, MoratuwaDr. Prasad WimalaratneSenior Lecturer, Head of the Department,Department of Communication and MediaTechnologies, University of Colombo School ofComputing, Colombo 07Dr. H. L. PremarathnaSenior Lecturer, University of Colombo School ofComputing, Colombo 07G. M. Niel GunadasaDirector of Education, ICT Branch,Ministry of Education, Isurupaya, BattaramullaK. G. S. K. PereraSenior Lecturer, Department of InformationTechnology, Faculty of Science and Technology,National Institute of Education, MaharagamaDakshina KasturiarachchiAssistant CommissionerEducational Publications DepartmentWriter BoardVineeta GoonetillekeLecturer, Sri Lanka Institute of InformationTechnology, MalambeG. K. N. S. Jeewanthi PereraVisiting Lecturer, University of Kelaniya, KelaniyaA. Sunil SamaraweeraCenter Manager, Zonal Computer Resource Center,Kegallevii

I. R. N. H. KarunarathnaCenter Manager, Zonal Computer Resource Center,President's College, MaharagamaK. V. S. M. MohanlalComputer Instructor, Zonal Computer ResourceCenter, Deniyaya Central College, DeniyayaE. G. W. JayasuriyaComputer Instructor, Zonal Computer ResourceCenter, Sri VijayaramaVidyalaya, Udahamulla,NugegodaP. J. K. KahagalleComputer Instructor, Zonal Computer ResourceCenter, President's College, MaharagamaB. A. N. D. SamarasinghaTeacher Service, Royal College, Colombo 07Language EditingK. D. D. PercivalRetired Senior Lecturer, Teachers’ Training College,MaharagamaCover PageChaminda HapuarachchiEducational Publications DepartmentTechnical AssistanceP. A. D. Nisansala SandamaliviiiEducational Publications Department

Index1Programming12System Development Life Cycle533The Internet and the Electronic Mail644Use of Multimedia815Web Designing Using Multimedia1256Information and CommunicationTechnology and Society168ix

1ProgrammingAfter studying this chapter, you will understand the following:²²²²²²How to analyze a problem and develop an algorithmControl structures and their useDrawing flow charts, writing pseudo codes and conversions between themFinding alternate solutions to a problemProgramming in PascalEvolution of programming languages1.1 Analyzing a problemThe raw materials that are used to solve a problem are known as the 'input'.The result obtained after solving a problem is known as the 'output'. Convertinginput to output is called the 'process'. A process takes place step by step and it isvery important to understand the order of the process. When analyzing a problem,the input, process and output are identified separately.Example Problem 1 :Preparing a letter which can be posted.Input :A sheet of paper suitable to write the letter on and a penAn envelope and a stampGlueProcess :1. Writing the letter2. Folding the letter and putting it intothe envelope3. Pasting the envelope4. Writing the recipient's address on theenvelope5. Sticking the stampOutput :A letter ready to be posted.Note:Steps No. 4 and 5 in this process can be interchanged.However, the other steps should be followed in the orderindicated.For free distribution1

Problem 2 :Making a cup of teaInput :Tea leaves, sugar, hot waterProcess :1. Putting tea leaves in the strainer2. Pouring hot water to the cup throughthe strainer3. Adding some sugar to the cup4. Stirring it well with a spoon5. Testing for taste, taking a small sip from the cup6. If the taste is not satisfactory, go to step 3 and repeat stepNos. 4 and 5Output :A cup of teaProblem 3 :Dividing 40 page and 80 page books from a parcel ofbooks between two siblings - Sanduni and Anupama.Input :The parcel of booksProcess :1. Opening the book parcel2. Taking a book out from the parcel3. If it is a 40 page book, giving it toSanduni4. If it is a 80 page book, giving it toAnupama5. Go to Step No. 2 till all the books are taken out of theparcelOutput :Sanduni getting 40 page booksAnupama getting 80 page booksProblem 4 :Adding two numbersInput :Two numbersProcess :Adding the two numbersOutput :TotalProblem 5 : Finding the area of a rectangle2Input :Length and width of the rectangleProcess :Area Length x WidthOutput :AreaFor free distribution

Problem 6 :Finding the larger number between two numbersInput :Two numbersProcess :Comparing the two numbers, finding the larger oneOutput :Larger numberProblem 7 :Finding whether a number is odd or evenInput :NumberProcess :Dividing the number by 2Deciding that the number is even ifthe remainder 0Deciding that the number is odd if the remainder 1Output :Indicating whether the number is odd or evenActivity1. Identify the input, process and output related to dividing 100 toffeesamong 20 people.2. Identify the input, process and output in making a kite.What are alternative solutions?If there is more than one solution to a given problem, such solutions arecalled alternative solutions. Such solutions depend on the nature of the problem.For free distribution3

ExampleImagine you come to school by school bus. If the bus breaks down on your way toschool, you certainly will think of other alternative ways to reach school. Thus, youwill think of alternative solutions to reach school.1. Coming to school by another school bus which goes to your school2. If you have money, reaching the school by CTB or private bus3. Walking to school along the road4. Walking to school using a short-cut5. If you have a way to inform your parents, get their support to reach theschool6. Reaching the school by car or motor bike with the support of a trustworthypersonYou may select a good solution out of these if it is mandatory to go to school thatday.Thus, if there are many solutions (set) to a particular problem, it is suitable toconsider these and select an appropriate solution.All the solutions pertaining to a problem are called solution space. In computerprogramming also, various solutions should be identified and an appropriatesolution should be selected. Then, we can create a short, simple program.Example 1Let us examine the solution space to find the perimeter of a rectangle.Let us analyze the input, process and output related to this problem.Input: Length and width of the rectangleProcess : Calculating the perimeterOutput : Indicating the perimeterLet us examine the solution space to calculate the perimeter.1st solutionPerimeter length width length width2nd solutionPerimeter length 2 width 23rd solutionPerimeter (length width) 2Out of these solutions, a person who has knowledge only of addition, can select the1st solution as the most appropriate. A person who has knowledge of multiplicationand addition can select the 3rd solution out of the 2nd and 3rd solutions as the mostappropriate. The reason for this is, it has the minimum number of additions andmultiplications.4For free distribution

Example 2Indicating that a student has failed if the score for the ICT Subject is less than 35,and indicating pass if the score is 35 or above.Input : MarksProcess : Comparing the mark scored with 35Solution 1.If the mark is less than 35Result FailIf notResult PassSolution 2.If the mark is 35 or more than 35Result PassIf notResult FailOutput : Fail or PassExample 3Finding the larger number from the given two numbers (See problem 6 in page 3)Let us consider the two input numbers as n1 and n2.Solution 1.If n1 is larger than n2, the larger number will be n1.If n2 is larger than n1, the larger number will be n2.Solution 2.Subtract n2 from n1.If the result is more than 0, n1 is the larger number.If the result is less than 0, n2 is the larger number.Thus, it is important to select the appropriate solution out of the available alternativesolutions.For free distribution5

1.2 Problem Solving using AlgorithmsAn algorithm is a method to show the steps in solving a problem. Analgorithm is a step-by-step procedure for solving a problem. The need for this is topresent a way to solve the problem with a plan.Example 1 - Let us develop an algorithm to post a letter.(1) Writing the letter(2) Folding the letter(3) Inserting the letter in an envelope(4) Writing the address(5) Sticking the stamp(6) Posting the letterStep (1), (2) and (3) in this algorithm should be followed in the given order.Step (4) and (5) can be interchanged. The reason for this is, you can either stick thestamp after writing the address or write the address after sticking the stamp.Thus, there are steps in an algorithm which should be followed in a strictsequential order. Sometimes, if the order of some steps is changed, it does not affectthe process and the output is same.Example 2 - Let us consider steps in measuring 500g of sugar using a scale.(1) Putting sugar into a bag(2) Placing the bag on the scale and getting the reading on thescale(3) If the weight of the sugar is less than 500g, add sugar tillit weighs 500g(4) If the weight of the sugar is more than 500g, remove sugarfrom the bag till it weighs 500g(5) Remove the bag of sugar from the scale when the weightis 500gThe algorithm to measure 500g sugar is given above.ActivityThere are 183 students in a primary school. The principal hasdecided to hold an inter-house sports meet dividing them into threehouses – Olu, Nelum and Manel. Develop an algorithm to the dividethe students into the three houses.6For free distribution

1.2.1 Control StructuresThree types of control structures are used in an algorithms.i.Sequenceii. Selectioniii. Repetitioni. SequenceIf the steps from the beginning to the end of an algorithm are carried out ina strict order, it is called a sequence.Example 1. Climbing up or down step by step when going on a staircase2. Students who were admitted to grade 1 of the schoolcontinue studies till grade 13ActivityWrite down two incidents which consist of sequences.ii. SelectionSelection is a situation where step(s) are executed depending on whether acondition of an algorithm is satisfied or not. There are two choices; if the conditionis satisfied, one is selected and if it is not satisfied, the other selection is selected.For free distribution7

Examples of selection1. Admitting a child to Grade 1:If a child is below 5 years as at 31st ofJanuary that yearThe child cannot be admitted to schoolIf notThe child can be admitted to school2. Passing a subject:If the mark is 35 or moreIt is a PassIf notIt is a Fail3. Buying a book:If you have money equal to or more thanthe price of the bookYou can buy the bookIf notYou cannot buy the bookActivity1. Write down three incidents which consist of selection.2. If a Sri Lankan citizen gets the right to vote after completing the ageof 18, select the most suitable word for the blanks given below.If the age is (more/less) than 18The vote (can/cannot ) be castedIf not,The vote (can/cannot) be castediii. RepetitionIf one or several steps of an algorithm are repeated until a condition issatisfied, it is called repetition.8For free distribution

Examples1. Let us consider the process of a class teachermarking the attendance register.(1) Call the first name on the register(2) Mark 1 if the student is present(3) Mark 0 if the student is absent(4) Call the name of the next student(5) Repeat step (2) or (3) and (4) till thelast name of the register is called2. Let us consider the process of reading a paragraphand calculating the number of words you read.(1) Read the first word of the paragraph(2) Number of words 1(3) Read the next word(4) Add 1 to the number of words(5) Repeat step (3) and (4) till the end of the paragraph(6) After reading the paragraph, indicate the number of wordsActivity1. Write down as steps, two scenario that comprise repetition.2. Fill in the blanks below related to repetition that output 5times from 5 to 60.I. n 5II. Output the value of n.III. Add 5 to the value of n.IV. Repeat step number and . till the valueof n 60.1.3 Representation of an algorithmFlow charts and pseudo codes are used as tools to present an algorithm tomake the algorithm understand better.For free distribution9

1.3.1 FlowchartsFlowcharts are used to present how the algorithm is built step by step in adramatic manner. The symbols given in table are used to indicate different functions.(See Table 1.1)Table 1.1SymbolFunctionStart or endInput or outputProcessDecisionFlow directionConnectorSequenceIn sequence the steps from the beginning to the end are executed in order.E.g. 1 - Finding the area of a circle.StartInput the radius of the circleCalculate the area of the circleOutput the area of the circleEnd10For free distribution

SelectionThe selection indicates the flow of direction depending on a condition beingsatisfied or not.E.g. - Finding whether a number is odd or evenStartInput the numberFind the remainder when thenumber is divided by 2Is the remainder 0?NoAn oddnum berYesAn even numberEndRepetitionA step or several steps are repeated till a condition is satisfied or arecontinued till it is satisfied.E.g. - Finding the total of some numbersStartTotal 0Get the number NTotal Total NAre there any morenumbers?NoOutput the TotalYesEndFor free distribution11

ActivityDraw flow charts to solve the problems given below.1. Find the perimeter and area of a rectangle.2. It is decided to add Rs.5000 to the basic salary of the employees ofa company. Calculate the new salary.3. When posting a letter, postal fare is charged according to its weight.The standard fare should be paid for letters which are equal to orless than the standard weight. An additional fare should be chargedif the weight is more than the standard weight.4. Indicate the first 12 multiples of 7.5. Draw flow charts for the examples in selection 1:2:1.1.3.2 Pseudo codesWhen an algorithm is presented in simple English terms it is called a pseudocode. Pseudo codes are independent of a computer language. Pseudo codes can beconverted to any programming language instructions. Hence, pseudo codes makecomputer programming easier.Let us see simple English terms used in an pseudo code.BEGIN - To indicate a beginningEND - To indicate an endINPUT , READ , GET - To indicate an inputOUTPUT, DISPLAY , SHOW - To show an outputPROCESS, CALCULATE - To indicate a processIF THEN . .ELSE ENDIF - Used to indicate a selectionFOR – DOWHILE – ENDWHILE Used to indicate a repetitionREPEAT - UNTIL}Writing pseudo codesE.g. 1 - Finding the area of a circleBEGININPUT RadiusCALCULATE Area 22/7 « Radius « RadiusDISPLAY AreaEND.12 For free distribution

E.g. 2 - Finding whether a number is odd or evenBEGINREAD number as NCALCULATE Remainder after number is divided by 2IF Remainder 0 THENDISPLAY “Even number”ELSEDISPLAY “Odd number”ENDIFEND.E.g. 3 - Finding the total of some numbersBEGINTotal 0REPEATREAD Number as NCALCULATE Total Total NUNTIL numbers are overDISPLAY TotalEND.E.g. 4 - Finding the total and the average of 10 numbersBEGINTotal 0Average 0n 1WHILE n 10READ NumberCALCULATE Total Total Numbern n 1ENDWHILECALCULATE Average Total/(n - 1)DISPLAY Total, AverageEND.For free distribution13

Following are some of the facts about the above pseudo code.²Total, Average and Number are variables. When values are assigned to number variable, the value of Total, Averageand n variables change.²n indicates the number of repetitions. (Number of times the loop is executed)²The statements Total 0 and Average 0, makes starting values of thesevariables assigned as 0. Hence, the initial value of Total and Average are 0s.²The statement n 1, makes the starting value of n is assigned to 1.²n 10 is the condition that should be satisfied.²WHILE n 10 indicates that the loop n should be repeated until value of n is10. Repetition occurs when the value of n is 10 or less than 10. This means,till the condition n 10 is true, repetition occurs. When the value of nbecomes 11, the repetition stops. Then the condition becomes false.²READ denotes getting a value for Number variable.²Total Total Number denotes thepresent value of Total is added tonumber and the resultant value isassigned on the new value of Total.²²n n 1 calculates the number ofrepetitions. 1 is added to the presentvalue of n and the result is assignedto n.Totaln1 1 20 12 12Totaln2 1 3numbernumber12 15 27numberTotalnENDWHILE indicates the limit toend repetition. Hence, only READnumber, Total Total Number and n n 1 are repeated till the condition n 10 is fulfilled.²When the repetition stops, the value of n is 11 and the condition is false.²By Average Total/(n - 1) , final value of Total is divided by (n – 1) and thatvalue is assigned to Average variable.²DISPLAY (Total, Average) produces the output of the total of 10 numbers andits average.14For free distribution

Observation²When a value is assigned to a variable, the previous value islost.²When the statement Total Total Number is executed, thevalue assigned to the Number variable is added with the valueassigned to Total variable and the result obtained is assignedto the Total variable.²Total Total Number is not a mathematical formula.1.3.3 Converting flow charts to pseudo codesAn algorithm can be presented in a flow chart as well as in a pseudo code.Hence, let us examine how a flow chart can be converted to a pseudo code.StartBEGINPut tea bag in cupPut tea bag in cupWHILE (not water boiled)Boil waterWater boiled?Boil waterNoENDWHILEYesPour water in cupPour water in CupStir teaWant sugar?WHILE (sugar needed)Add sugarStir teaYes Add sugarENDWHILENoEndENDFor free distribution15

E.g. 1 - Finding the larger number from two different numbersStartBEGINREAD N1, N2Input the two numbersN1, N2IF N1 N2 THENLarge N1Is N1 larger thanN2?YesELSELarger number isNoN2Large N2ENDIFLarger number is N1DISPLAY LargeEnd.Output the largernumberEndE.g. 2 - Finding the smallest number from 10 input numbersStartInput the number NMin NCount 1Count 10 ?Count Count 1NoYesInput NN Min ?YesMin N16For free distributionNoOutput MinEnd

BEGININPUT Number as NMin NCount 1WHILE Count 10OUTPUT Number as NIF N Min ThenMin NENDIFCount Count 1ENDWHILEPRINT MinEND.1.4 Pascal programming1.4.1 IdentifiersAn identifier is a term used to represent a variable, constant or a program.The following are some rules that should be followed in declaring an identifier.²Reserved words in Pascal cannotbe used as an identifier name.In any programming languagereserved words cannot be used asidentifiers.reserved wordE.g. - BEGIN, END are not valid(E.g. - A-Z, a-z)variable identifierVar year : integerinteger;data type²Should start with an English letter.²After the first letter of the identifier, letters (a-z, A-Z) or numbers (0-9) andunderscore ( ) can be used.E.g. - Student name²Not case sensitive (E.g. - Art, art, ART will be the same identifier)²There should not be any space between words.E.g. - Student Name - Not validFor free distribution17

²The special characters such as the following should not be included in anidentifier. ! @ # % & * ( ) - { } [ ] : ; ‘ “ ? , . / \but, only underscore ( ) is valid.²Use of meaningful terms for identifiers can make program easily understood.Examples of valid identifiersSum, SUM, Total Nos, Num1, FirstName, Last NameExamples of identifiers that are not valid 75, Average Marks, 9A, Last-name1.4.2 Reserved wordsThe reserved words in Pascal, are defined in Pascal language. Hence,reserved words are not used as identifiers.Reserved words are different from language to language. The following arereserved words used in aryFor free sesvarwhilewithxorateto

1.4.3 Standard data types in PascalWhen a program is executed, the input and output should be stored incomputer memory. The space needed for each is defined according to the data type.Hence, it is essential for a programmer to have knowledge of data types.The following are data types and their ranges.Integer - Plus or minus whole numbersE.g. - 0, 46, -12Real - Plus or minus decimal numbersE.g. - 0.0, 25.68BooleanTrue or FalseChar - Any character of the keyboardE.g. - ‘k’, ‘#’, ‘7‘String - Any sequence of charactersE.g. - ‘ICT’, ‘programming’, ‘Sri Lanka’rtantImpoValues of Char and String are included inside single quotation ‘ ’.1.4.4 Variables and constantsVariableA variable is an identifier which changes the values given to it when theprogram is being executed.For free distribution19

In Pascal, “var” is used to declare variables.RetriveStoreE.g. - var count : integer;var a,b : real;varn1, n2 : integer;Avg : real ;Pass : boolean;Character : char;Name,school : String;rtantImpoA variable has a name, and it stores a value of the declared type.ConstantsThe identifiers which do not change their values while the program isexecuted are called constants. In Pascal, “const” is used to declare a constant.ExampleConstConstmax 100;pi 22/7;Observation²When executing a program, a variable can take differentvalues. However, the value of a constant remains unchanged.1.4.5 OperatorsOperators are required to perform calculations, comparisons, and to evaluatelogical expressions. Hence, operators are essential in programming.20For free distribution

Basic types of operators1. Algebra operatorsOperator */DIVMODUsageExample expressionAddition6 on of round numbers 20 DIV 6Remainder after division 20 MOD 636 20182Result92102.5032DIVMOD2. Comparison operatorComparison operators are used to compare values or expressions. The finalresult of an expression which consists of a comparison always takes a Booleanvalue. Hence expression will be True or False.Function UsageExample expressionGreater than7 3Greater than or equal8 8Less than3 2Less than or equal4 6Equal3 1Not equal2 5ResultTrueTrueFalseTrueFalseTrue3. Logical operatorsLogical operators are used to combine two or more expressions. For furtherstudy on this refer. basic logic gates that you learnt in Grade 10.For free distribution21

i) AND operatorAND operator takes the form “(First Expression) AND (SecondExpression)”. Depending on the first expression or second expression being Trueor False, the result becomes True or False. The following table shows the functionof AND.First Expression Second Expression (First Expression) AND eFalseFalseTrueTrueTrueExample1.2.3.(Rain fall 56) AND (Temperature 30)(Height 60) AND (Age 15)Let us consider, (3 2) AND(3 3)3 2 is True. 3 3 is False. Hence, the result of the expression is False.rtant If at least one operator out of the two operators is false, the ANDevaluates to false.Impo When only both operators are true, the expression of ANDevaluates to true.ii) OR operatorOR operator takes the form “(First Expression) OR (Second Expression)”.Depending on the first expression and second expression being True or False, theresult of OR is True or False. The following table shows the function of the ORoperator.22First expressionSecond expressionFalseFalse(First expression) OR rueTrueTrueFor free distribution

Example1. (Temperature 30) OR (Rainfall 55)2. Let us consider, (3 2) OR (3 3)3 2 is True. 3 3 is false. Hence, the result of the expression is true.rtant When at least one operator out of the two operators is true, theOR operator evaluates to true.Impo When only both operators are false, the expression of OR operatorevaluates to false.iii) NOT operatorA True expression is always evaluated as false with a NOT operator while afalse expression is always evaluated as true.ExpressionFalseTrueNOT (Expression)TrueFalseExample1. NOT (Temperature 30)2. NOT(5 5) is indicated as false statement.Therefore 5 5 is a true expression. Hence, the statement NOT (5 5) isindicated as falseOperator precedenceWhen Pascal expressions are evaluated, the order of precedence is givenbelow.Priority order1234OperatorNOT*/DIV OR highMOD AND For free distributionless23

Evaluating expressionsE.g. -316 / 4 * 24*28E.g. 15 14 MOD 45 27E.g. 23 7 DIV 23 36E.g. 4NOT (8 MOD 2 5)NOT (0 5)NOT(False)trueE.g. -54 4 AND NOT(7 9)True AND NOT(False)True AND TruetrueLet us identify the basic components of a normal Pascal program.program addNum (input,output); Name of the program (addNum)varnum1,num2,total : integer;Declaring the variablesavg: real;}BeginOutputEnd.IndicatingcommentsBeginning of the main programWrite(‘Welcome Pascal Programming’);{calculate total and average of two numbers}Writeln(‘Enter First Number’);Read(num1);Writeln(‘Enter Second Number’);InputRead(num2);total: num1 num 2; Expressions which indicateavg : total/2;the processwriteln(‘Total is ‘ , total);writeln(‘Average is ‘ , avg);}Ending of the main programNote : To write comments (*.*) can also be used.²“program”, “input” and “output” are reserved words.²“addNum” is an identifier. This is the name of the program. It is not essential toindicate input, output within brackets with the program name.²read( ) and readln( ) functions words are used for input.¾ Data is input to num1 variable through Read(num1);¾ Data is input from readln() from a new row.24For free distribution

²write( ) and writeln( ) functions are used for output.¾ From the function Write(‘Welcome Pascal Programming’) outputs'Welcome Pascal Programming'.¾ The function writeln(‘Average is ‘ , avg); prints the value of the Avgvariable in a new line.When writing Pascal statements;²²²Semi-colon (;) is used at the end of anstatement. Semi-colon indicates the end ofan statement.Total5.7num 1 3.4num 2 2.3What happens with the expressiontotal :} num1 num2 is that it adds thevariables num1 and num2 and assign resultto the variable 'total'“:}’’ is the assignment operator.i: integeri : 4;1.4.6 SelectionIF statementIf condition structure is as follows.NoIs the conditionTrue?YesStatement(s)IF Condition THENStatement(s)ENDIFPseudo CodeFlow chartFor free distribution25

There are two types of IF statements.i) IF. THEN. ENDIFHere, the statement will be executed if only the condition is satisfied.E.g. 1 - If the input number is only positive, print the number.StartGet the number (N)Is N 0?NoYesPseudo CodePrint NEndFlow chartBeginInput NIF N 0THENP

Grade 11 Educational Publications Department. ii First Print - 2015 Second Print - 2016 Third Print - 2017 Fourth Print - 2018 Fifth Print - 2019 . Opening the book parcel 2. Taking a book out from the parcel 3. If it is a 40 page book, giving it to Sanduni