computer programming –i - strawberry -...

50

Upload: buiminh

Post on 23-Mar-2018

225 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether
Page 2: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

ComputerProgramming–I

DevelopedByStrawberry

Page 3: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

CourseOutcome•  AWerSuccessfulcompleIonofthiscourse,studentswillbeableto–  Illustrateflowchartandalgorithmforagivenproblem

– DevelopandExecuteCprogramsusingbasicprogrammingconstructs.

–  ImplementCprogramsusingvariousdatatypesandfuncIons

–  SolveproblemsusingPointers

DevelopedByStrawberry

Page 4: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Algorithms&Flowchart

DevelopedByStrawberry

Page 5: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

WhatisanAlgorithm?

•  ComputerScienIstNiklausWirthstatedthat– Program=Algorithms+Data

– Algorithm:Procedureforsolvingaprobleminfinitenumberofsteps.

DevelopedByStrawberry

Page 6: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

ExampleforAlgorithm

•  Makingapotoftea:1.  IfthekeJledoesnotcontainwater,thenfillthe

keJle.2.  PlugthekeJleintothepowerpointandswitchiton.3.  Iftheteapotisnotempty,thenemptytheteapot.4.  Placetealeavesintheteapot.5.  IfthewaterinthekeJleisnotboiling,thengoto

step5.6.  SwitchoffthekeJle.7.  PourwaterfromthekeJleintotheteapot.

DevelopedByStrawberry

Page 7: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

ExampleforAlgorithm•  Makingapotoftea:

1.  IfthekeJledoesnotcontainwater,thenfillthekeJle.(Decisionmaking)

2.  PlugthekeJleintothepowerpointandswitchiton.

3.  If the teapot is not empty, then empty theteapot.(Decisionmaking)

4.  Placetealeavesintheteapot.5.  If thewater in thekeJle isnotboiling, thengo

tostep5.(Repe::on)6.  SwitchoffthekeJle.7.  PourwaterfromthekeJleintotheteapot.DevelopedByStrawberry

Page 8: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

AlgorithmFeatures

•  Sequence(alsoknownasprocess)•  Decision(alsoknownasselecIon)•  RepeIIon(alsoknownasiteraIonorlooping)

DevelopedByStrawberry

Page 9: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Sequence

•  Each step or process in the algorithm isexecutedinthespecifiedorder.

DevelopedByStrawberry

Page 10: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Thedecisionconstructs–if…then..else

•  Outcomeofadecision–eithertrueorfalse.–  IftodayisFridaythencollectpay.

•  It iseither true that ‘today is Friday’or it is false that‘todayisnotFriday’.

•  Itcannotbeboth.•  GeneralForm:IfProposiIonIfFridaythenprocess1thencollectpayelseelseprocess2callonnextMonday

DevelopedByStrawberry

Page 11: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

RepeIIon•  RepeataprocessorsequenceofprocessunIlacondiIonbecomestrue.

•  GeneralForm:RepeatRepeatProcess1FillwaterinkeJleProcess2UnIlKeJleisfull……………..ProcessNUnIlProposiIon

DevelopedByStrawberry

Page 12: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

RepeIIon-While•  WhathappensifthekeJleisalreadyfull?•  Whileloopmoreappropriate.WhileproposiIonWhilekeJleisnotfullbeginfillwaterinkeJle.Process1

DevelopedByStrawberry

Page 13: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

RepeIIon–Ifthengoto1.  FillsomewaterinkeJle2.  IfkeJlenotfullthengoto1.

DevelopedByStrawberry

Page 14: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Variables1.  Program consists of algorithm (Process) and

data.2.  Dataneedstobestored.3.  Data is contained(stored) inwhat is calleda

‘variable’.4.  The variable is a container of a value that

may change during the execuIon of theprogram.

DevelopedByStrawberry

Page 15: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Variables1.  Eachvariableinaprogramisgivenaname2.  Example: Water_Level, Water_Temprature,

Num1,Num2Howtousevariableinalgorithm?IfWater_Levelis0thenfillthekeJle.

DevelopedByStrawberry

Page 16: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Rulesforalgorithm1.  Eachalgorithmwillbe logicallyenclosedby

twostatementsSTARTandSTOP.

2.  Toacceptdatafromuser,theINPUTorREADstatementsaretobeused.

3.  Todisplayanyusermessage,or thecontentinavariablePRINTstatementwillbeused.

DevelopedByStrawberry

Page 17: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Rulesforalgorithm–ArithmeIcOperators

1.  ‘ß’Assignmentoperator xß 6 means the value 6 is assigned to thevariablex.ZßX+Y(ValueofX+ValueofY)assignedtoZZßX-YXß5Yß6ZßX*YZßX/Y

DevelopedByStrawberry

Page 18: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Rulesforalgorithm–RelaIonalOperators1.  ‘>’greaterthan

X>Y means if thevaluecontained inX is larger thanthat inYthen outcome of the expression is true else outcome ofexpressionisfalse.‘<=‘LessthanorequaltoX<=Y means that if the value held in X is either less than orequal to thevalueheld inY thenoutcomeof theexpression istrueelsefalse.OtherrelaIonaloperators:>,>=,=,!=(Notequalto)

DevelopedByStrawberry

Page 19: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Rulesforalgorithm–Logicaloperators1.  ‘AND’conjuncIonTheoutcomeof theexpression is truewhenbothproposiIonsaretrueotherwiseitisfalse.Xß2Yß1X=2ANDY=0X=2truebutY=0isfalseSooutcomeoftotalexpressionisfalse.

DevelopedByStrawberry

Page 20: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Rulesforalgorithm–Logicaloperators2.  ‘OR’DisjuncIonThe outcome of an expression is true when anyone of theproposiIonsistrueelseitisfalse.Xß2Yß1X=2ORY=0X=2istruebutY=0isfalseBut as ‘OR’ is used as one proposiIon is true result for enIreexpressionwillbetrue.

DevelopedByStrawberry

Page 21: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

AlgorithmExampleAlgorithmforfindingthesumofanytwonumbers.SoluIon:LetthetwonumbersbeAandBandlettheirsumbeequaltoC.Then,thedesiredalgorithmisgivenasfollows:1.  START2.  PRINT“ENTERTWONUMBERS”3.  INPUTA,B4.  CßA+B5.  PRINTc6.  STOP

DevelopedByStrawberry

Page 22: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

AlgorithmExampleAlgorithm for determining the remainder of a division operaIonwherethedividendanddivisorarebothintegers.SoluIon: Let N and D be the dividend and divisor, respecIvely.Assume Q to be the quoIent, which is an integer, and R to be theremainder.Thealgorithmforthegivenproblemisasfollows:1.  START2.  PRINT“ENTERDIVIDEND”3.  INPUTN4.  PRINT“ENTERDIVISOR5.  INPUTD6.  QßN/D(INTEGERDIVISION)7.  RßN-Q*D8.  PRINTR9.  STOP

DevelopedByStrawberry

Page 23: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

AlgorithmExampleConstructthealgorithmforinterchangingthenumericvaluesoftwovariables.Hint: If A and B are two variables with values 5 and 6respecIvely. Interchange values ofA andB, so that valueofAwillbecome6andvalueofBwillbecomeA.UsethirdvariableCforit.

DevelopedByStrawberry

Page 24: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

AlgorithmExampleSoluIon: Let the two variablesbeA andB. ConsiderC tobe athird variable that is used to store the value of one of thevariablesduringtheprocessofinterchangingthevalues.Thealgorithmforthegivenproblemisasfollows:1.  START2.  PRINT“ENTERTHEVALUEOFA&B”3.  INPUTA,B4.  CßA5.  AßB6.  BßC7.  PRINTA,B8.  END

DevelopedByStrawberry

Page 25: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

AlgorithmExampleWriteanalgorithmthatcomparestwonumbersandprintseitherthemessage idenIfying the greater number or themessage staIng thebothnumbersareequal.SoluIon:LetAandBbetwovariablestorepresentthetwonumbersthat are being compared. The algorithm for this problem is given asfollows:1.  START2.  PRINT“ENTERTWONUMBERS”3.  INPUTA,B4.  IFA>BTHEN

PRINT“AISGREATERTHANB”5.  IFB>ATHENPRINT“BISGREATERTHANA”6.  IFA=BTHENPRINT“BOTHAREEQUAL”7.STOP

DevelopedByStrawberry

Page 26: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

AlgorithmExampleWriteanalgorithmprintthelargestnumberamongthreenumbers.SoluIon:LetthethreenumbersberepresentedbyA,BandC.SoluIonforthealgorithmisasfollows:

SoluIon11.  START2.  PRINT “ENTER THREE

NUMBERS”3.  INPUTA,B,C4.  IFA>=BANDB>=CTHENPRINTA5.  IFB>=CANDC>=ATHENPRINTB6.  ELSEPRINTC7.STOP

SoluIon21.  START2.  PRINT“ENTERTHREE

NUMBERS”3.  INPUTA,B,C4.  IFA>CTHENIFA>CTHENPRINTAELSEPRINTCELSEIFB>CTHENPRINTBELSEPRINTC5.STOPDevelopedByStrawberry

Page 27: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

AlgorithmExampleTakethreesidesofatriangleasinputandcheckwhetherthetrianglecanbedrawnornot.Classifythetriangleasequilateral,isosceles,orscalene.SoluIon: Let the length of three sides of triangle be represented by A,B and C.SoluIonforthealgorithmisasfollows:

SoluIon11.  START2.  PRINT“ENTERLENGTHOFTHREESIDESOFATRAINGLE”3.  INPUTA,B,C4.  IFA+B>CANDB+C>AANDA+C>BTHENPRINT”TRAINGLECANBEDRAWN”ELSEPRINT“TRIANBLECANNOTBEDRAWN”:GOTO6.5.  IFA=BANDB=CTHENPRINT“EQUILATERAL”ELSEIFA!=BANDB!=CTHENPRINT“SCALENE”ELSEPRINT“ISOSCELES”6.STOP

DevelopedByStrawberry

Page 28: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

AlgorithmExampleConstruct an algorithm for incremenIng the value of a variable that startswith aniniIalvalueof1andstopswhenthevaluebecomes5.SoluIon:LetthevariableberepresentedbyC.Thealgorithmforthesaidproblemisgivenasfollows:1.  START2.  Cß13.  WHILEC<=54.  BEGIN5.  PRINTC6.  CßC+17.  END

DevelopedByStrawberry

Page 29: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

AlgorithmExampleWriteanalgorithmfortheaddiIonofNgivennumbers.SoluIon:LetthesumofNgivennumbersberepresentedbyS.1.  START2.  PRINT“HOWMANYNUMBERS?”3.  INPUTN4.  Sß05.  Cß16.  PRINT“ENTERNUMBER”7.  INPUTA8.  SßS+A9.  CßC+110.  IFC<=NTHENGOTO611. PRINTS12. STOP

DevelopedByStrawberry

Page 30: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Whatisaprogramflowchart?•  Atoolusedbyprogrammerstodevelopprogramlogic

•  Logicdiagram•  DiagrammaIcrepresentaIonofalgorithm

Start

Open Files

Read a Record

Write a Line

EOF?

No Yes

Close Files Stop

DevelopedByStrawberry

Page 31: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Whydoprogrammersuseflowchartstodevelopprogramlogic?

•  Flowchartsareagoodvisualreferenceofwhattheprogramwilldo

•  ServeasprogramdocumentaIonandasacommunicaIonstool

•  AllowtheprogrammertotestalternaIvesoluIons

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

DevelopedByStrawberry

Page 32: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Whataretheflowchartsymbols?The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

DevelopedByStrawberry

Page 33: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

TerminalSymbolThe image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.Designates the beginning or end of a program or

routine

START STOP

DevelopedByStrawberry

Page 34: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Input/Output(I/O)SymbolThe image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

Denotes an operation involving an input or output device

OPEN FILES

READ A RECORD

WRITE A LINE

CLOSE FILES

DevelopedByStrawberry

Page 35: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

ProcessSymbolThe image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

Used for move instructions and arithmeIc instructions

AVERAGE = (SCORE1 +

SCORE2) / 2

MOVE SCORE1 TO

ACCUMULATOR

DevelopedByStrawberry

Page 36: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

DecisionSymbolThe image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

Designates that different logic paths will be followed based on a condition occurring in a program

IS A = B? Yes

No

CODE = ?

1 2 3 4 5

DevelopedByStrawberry

Page 37: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

PreparaIonSymbolThe image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

Assigns initial values to areas in storage and does whatever else is necessary to get ready for processing

COUNTER = 0

DevelopedByStrawberry

Page 38: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

AnnotaIonSymbolThe image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

Describes or shows comments on the flowchart

AVERAGE = (SCORE1 +

SCORE2) / 2

CALCULATE AVERAGE

DevelopedByStrawberry

Page 39: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

FlowlineSymbolThe image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

Links other symbols and indicates the sequence of operations

• Normal flow is top to bottom and left to right

• Arrowheads must be used when the flow is other than the normal flow

DevelopedByStrawberry

Page 40: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

ConnectorSymbolThe image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.Connects parts of the flowchart when the

use of flowlines would be confusing or otherwise undesirable

X : 3 A=

<>

DevelopedByStrawberry

Page 41: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Off-pageConnectorSymbolThe image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

Connects parts of the flowchart from one page to another

COMPAREX TO 3 =

< >

p. 2B

DevelopedByStrawberry

Page 42: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

MoreRules...•  AvoidintersecIngflowlines

START

STOP

B

C

B

A

C

A

START

STOPDevelopedByStrawberry

Page 43: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Morerules

•  AvoidmulIpleflowlinesenteringasymbol

DevelopedByStrawberry

Page 44: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

ExampleinSecIon2.4(page34)

•  InstrucIons– Open–  Read– Move– Write–  Close–  Stop

•  Areasinstorage–  Inputareas– Outputareas– Workareas

Start

Open Files

Read a Record

Write a line

Close Files

Stop

DevelopedByStrawberry

Page 45: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

StartandStop•  Start

– FirstinstrucIonofflowchart•  Stop

– LastinstrucIonexecuted•  StartandStopinstrucIonsareinterminalsymbols

Start

Open Files

Read a Record

Write a line

Close Files

Stop

DevelopedByStrawberry

Page 46: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

Flowchartexampleforaddingtwonumbers

START

InputA,B

Print“EntervalueforAandB”

CalculateC=A+B

PrintC

STOPDevelopedByStrawberry

Page 47: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

FlowchartExample•  DrawaflowchartforcalculaIngthesimpleinterestusingtheformula

•  SI=(P*T*R)/100•  WherePdenotestheprincipalamount,TImeandRrateofinterest.

DevelopedByStrawberry

Page 48: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

FlowchartExample•  Drawaflowcharttofindthesumofthefirst50naturalnumbers.

DevelopedByStrawberry

Page 49: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether

FlowchartExample•  DrawaflowcharttofindthelargestofthreenumbersA,BandC.

DevelopedByStrawberry

Page 50: Computer Programming –I - Strawberry - Homestrawberrydevelopers.weebly.com/uploads/5/2/3/5/52354675/...Algorithm Example Take three sides of a triangle as input and check whether