unit-3

download unit-3

of 107

description

s

Transcript of unit-3

  • UNIT - 3PROBLEM SOLVING AND OFFICE AUTOMATION

  • ProgramProgram is a collection of instructions that will perform some task.

  • Problem Solving StepsAnalyse the problem.Identify the solution for the problem and divide it into small task.Algorithm has to be prepared.Based on the algorithm the program will be created.Then it has to be executed.

  • Program Development CycleMethodologiesProgram planning methodWaterfall method etc,.

  • Program planning methodSpecificationReviewInformal DesignTest & DebugCodingFormal DesignMaintaining

  • Specification reviewcollect the requirementsunderstand the requirementsInformal DesignIdentifies the major tasksIdentifies the subtasksFormal DesignIt converts the informal design to some format that can be understand by others.

  • CodingIt converts the Design into Programs.It translate these programs to machine language.Test & DebugIt use sample data to test whether it works properly.It also eliminate the errors.

  • MaintainingIt Modifies the programs if necessary.

  • Waterfall methodFeasibilityAnalysisMaintenanceTestingImplDesign

  • FeasibilityIt determines whether it is possible to create the project or not.It also produce the plans and the estimates.AnalysisIt get the requirements from the customer.It analysis the requirements.

  • DesignIt is the process of designing how the requirements to be implemented.

    ImplementationIt converts the designs into code.After coding it use language translators to compile the code.

  • TestingHere the modules are integrated together.Then the project is tested and find whether it meets the customer/user requirements.

    MaintenanceIt make modifications based on the customer feedbacks.

  • AlgorithmAlgorithm is a finite sequence of instructions required for producing the desired result.

  • CharacteristicsThe steps in the algorithm must be unambiguous .It should be written in sequence.Ensure that the algorithm will terminate.It should conclude after a finite number of steps.

  • Factors used to judge the algorithm TimeMemoryAccuracySequence etc,.

  • RepresentationsFlowchartsNormal EnglishPseudo code etc,.

  • ExampleAddition of two numbersStep1: StartStep2: Read a, bStep3: Add the value of a with b and store the result in c.Step4: Display the value of cStep5: Stop

  • FlowchartsIt is the pictorial representation of the algorithm.

  • Flowchart SymbolsTerminal symbolIt is used to represent the start, end of the program logic.

    Input/OutputIt is used for input or output.

    Process SymbolIt is used to represent the calculations, data movements, initialization operations etc,.

  • Decision Symbol

    It is used to denote a decision to be made at that point

    Flow linesIt is used to connect the symbols

    ConnectorsIt is used to connect the flow lines.

  • Guidelines for preparing flowchartsIt should be simple.Standard symbols should be used.The flow lines should not intersect each others.In case of complex flowcharts use the connectors symbols.

  • Only one flow line should enter the process symbol and only one flow line should come out from a process symbol.

    Only one flow line used with the terminal symbol.

    STARTSTOP

  • Only one flow line should enter the decision symbol and two or three flowlines may leave from the decision symbol.

  • Benefits of FlowchartsMakes Logic ClearCommunicationEffective AnalysisUseful in coding Useful in Testing etc,.

  • Limits of FlowchartsIt is difficult to use flowcharts for large programDifficult to modifyCost etc,.

  • Pseudocode Pseudo means imitates and code means instruction.It is formal design tool.It is also called Program Design Language.

  • KeywordsREAD,GETPRINT,DISPLAYCOMPUTE,CALCULATE

  • Guideline for writing PseudocodeSteps should be understandableCapitalize the keyword.Indent to show hierarchy.End multiple line structure etc,.

  • Example

    READ a,bC=a+bWRITE Cstop

  • ExampleREAD a,bIF a>bPRINT a is greaterELSEPRINT b is greaterENDIFstop

  • Advantage & DisadvantageIt can be easily modifiedIt can be understood easilyCompare to flowchart it is difficult to understand the program logic.

  • Sequence control structureFlow chartPseudocodeProcess 1Process 2

    Process nProcess 2Process nProcess 1Design Structures

  • Sequence control structureThe instructions are computed in sequence i.e. it performs instruction one after another.It uses top-down approach.

    Design Structures

  • ExampleSTARTC=a+bPrint cRead a,bSTOP

  • SELECTION CONTROL STRUCTUREIt is used for making decisions.It allows the program to make a choice from alternative paths. IF THENIF THEN ELSECASE etc.,

  • IFTHENPseudocodeFlow chartIF condition THENprocess 1.. END IF..

    If conditionNOYESProcess 1

  • ExampleStartRead aIf a>0Print a is PositiveStopnoyes

  • IFTHENELSEPseudocodeFlowchart

    IF condition THENprocess 1..ELSEprocess 2.. END IF..If conditionYESNOProcess 1Process 2

  • ExampleStartRead a,bIf a>bPrint a is GreaterPrint b is GreaterStopnoyes

  • CASE structurePseudocodeFlow chart..CASE TypeCase Type-1:Process 1Case Type-2:Process 2..Case Type-n:Process n..END CASEType 1Type 2Type 3Process 1Process 2Process 3nononoyesyesyes

  • startstopRead m1,m2,m3Avg=(m1+m2+m3)/3If Avg>=60If Avg>=50

    If Avg>=35

    Fail

    Print First ClassPrint Second ClassPrint Third ClassExample: Finding the Grade

  • Looping control structureIt is used to execute some instructions several time based on some condition.WHILE loopDoWHILE loop etc.,

  • WHILE Loop PseudocodeFlow chart..WHILE condition..Body of the loop..END WHILEBody of The loopconditionnoyes

  • ExampleStartNum=0Num=Num+1Print NumwhileNum
  • DOWHILE Loop PseudocodeFlow chartDO ..Body of the loop..WHILE condition..

    END WHILEBody of The loopconditionnoyes

  • ExampleStartNum=0Num=Num+1Print NumwhileNum
  • Example: Finding the area of a circleAlgorithm Step1: StartStep2: Read the value of rStep3: Calculate area = 3.14*r*rStep4: Print areaStep5: Stop

  • Pseudocode

    Set areaREAD the rCOMPUTE area=3.14*r*rPRINT areastop

  • FlowchartSTARTarea=3.14*r*rPrint areaRead rSTOP

  • Find the largest among three NumbersAlgorithm Step1: StartStep2: Read the value of a, b, cStep3: IF (a>b) and (a>c) THEN print a is largest ELSE IF (b>c) THENprint b is largest ELSE print c is largestStep4: Stop

  • Pseudocode

    READ a, b, cIF (a>b) and (a>c) THENWRITE a is largestELSE IF (b>c) THENWRITE b is largestELSE WRITE c is largestENDIFstop

  • FlowchartSTARTPrint b Is largestRead a,b,cstopIf (a>b) and (a>c)If b>cPrint a Is largestPrint c Is largestnoyesyesno

  • Finding roots of the Quadratic equationStep:1 StartStep:2 Enter the values of a,b,cStep:3 Find the value of D Using the Formula, D = b*b-4*a*cStep:4 If D is greater than or equal to zero find 2 rootsroot1(-b+sqrt(D))/(2*a)root2(-b-sqrt(D))/(2*a)Step:5 Print root1 & root2Step:6 If D is less than zero, then print the roots are imaginaryStep:7 Stop

  • PseudocodeSet root1,root2READ the value of a, b, cFind D b*b-4*a*cIF D>=0 THEN calculate root1=(-b+sqrt(D))/(2*a) root2=(-b-sqrt(D))/(2*a)ELSERoots are imaginaryEND IFWRITE root1,root2Stop

  • Flow chartStartStopD=b*b-4*a*cRoot1=[-b+sqrt(D)]/(2*a)Root2=[-b+sqrt(D)]/(2*a)Read a,b,cPrint root1,root2If D>=0noyesPrintroots are imaginary

  • Swapping two variablesAlgorithm Step1: StartStep2: Read the value of a, bStep3: c = a a = b b = cStep4: Print the value of a and bStep5: Stop

  • Pseudocode

    READ the value of a, bTo swap usec = aa = bb = cWRITE a, bstop

  • FlowchartSTARTc = aa = bb = cPrint a, bRead a, bSTOP

  • Swapping two variables without using another variableAlgorithm Step1: StartStep2: Read the value of a, bStep3: a = a + b b = a - b a = a - b Step4: Print the value of a and bStep5: Stop

  • Pseudocode

    READ the value of a, bTo swap use a = a + b b = a - b a = a - bWRITE a, bstop

  • FlowchartSTARTa = a + bb = a - ba = a - bPrint a, bRead a, bSTOP

  • Finding the year is leap year or notAlgorithm Step1: StartStep2: Read the value of yearStep3: IF year % 4 ==0 THEN print It is a Leap year ELSE print It is not a Leap year Step4: Stop

  • Pseudocode

    READ yearIF year % 4 ==0 THENWRITE It is a Leap year ELSE WRITE It is not a Leap year ENDIFstop

  • FlowchartStartRead yearyear % 4 ==0Print It is a Leap yearPrint It is not a Leap yearStopnoyes

  • Finding the FactorialAlgorithm Step1: StartStep2: Read the value of n and set i =1Step3: While i
  • Pseudocode

    READ the value of n and set i =1WHILE (i

  • FlowchartStartRead ni = 1fact=fact * ii=i+1Print factwhilei
  • Finding the Sum of the digitsAlgorithm Step1: StartStep2: Read the value of n and set i = 0, sum = 0Step3: While n>0 dor=n%10sum=sum + rn=n/10 else Goto step5Step4: Goto step 3Step5: print the value of sumStep6: Stop

  • Pseudocode

    READ the value of n and set i =0, sum=0WHILE (n>0) do r=n%10 sum=sum + r n=n/10ENDWHILERepeat the loop until condition failsWRITE sumstop

  • FlowchartStartr = 0,sum=0r=n%10sum=sum + rn=n/10Print sumwhilen>0stopnoyesRead n

  • Finding the Reverse of a NumberAlgorithm Step1: StartStep2: Read the value of n and set i = 0, sum = 0Step3: While n>0 dor=n%10sum=sum *10 + rn=n/10 else Goto step5Step4: Goto step 3Step5: print the value of sumStep6: Stop

  • Pseudocode

    READ the value of n and set i =0, sum=0WHILE (n>0) do r=n%10 sum=sum *10 + r n=n/10ENDWHILERepeat the loop until condition failsWRITE sumstop

  • FlowchartStartr = 0,sum=0r=n%10sum=sum *10 + rn=n/10Print sumwhilen>0stopnoyesRead n

  • Armstrong NumberExample: 153

    13 +53 + 33 =153

  • Finding an Armstrong NumberAlgorithm Step1: StartStep2: Read the value of n and set a = n, sum = 0Step3: While n>0 dor=n%10sum=sum + r*r*rn=n/10 else Goto step5Step4: Goto step 3Step5: If a = sum thenPrint Armstrong Number ElsePrint It is Not an Armstrong Number EndifStep6: Stop

  • PseudocodeREAD the value of n and set a =n, sum=0WHILE (n>0) do r=n%10 sum=sum + r*r*r n=n/10ENDWHILERepeat the loop until condition failsIF a=sum THENWRITE Armstrong NumberELSEWRITE It is not an Armstrong NumberENDIFstop

  • FlowchartStarta = n,sum=0r=n%10sum=sum + r*r*rn=n/10Print Armstrong Nowhilen>0stopnoyesRead nifa=sumPrint It is Not an Armstrong No

  • Fibonacci seriesExample:

    0 1 1 2 3 5 8 11.

  • Finding the Fibonacci seriesAlgorithm Step1: StartStep2: Read the value of n and set f=0,f1=-1, f2=1 Step3: While (f
  • Pseudocode

    READ the value of n and set f=0 ,f1=-1, f2=1 WHILE (f

  • FlowchartStartf=0,f1= -1,f2=1f=f1+f2f1=f2f2=fPrint fwhilef
  • Conversion of Celsius to FahrenheitAlgorithm Step1: StartStep2: Read the value of Celsius Step3: Fahrenheit = (1.8* Celsius) + 32Step4: Print Fahrenheit Step5: Stop

  • Pseudocode

    Set FahrenheitREAD the CelsiusCOMPUTE Fahrenheit = (1.8* Celsius) + 32PRINT Fahrenheitstop

  • FlowchartSTARTFahrenheit = (1.8* Celsius) + 32 Print FahrenheitRead CelsiusSTOP

  • Conversion of Fahrenheit to CelsiusAlgorithm Step1: StartStep2: Read the value of FahrenheitStep3:Calculate Celsius =(Fahrenheit 32)/1.8Step4: Print CelsiusStep5: Stop

  • Pseudocode

    Set CelsiusREAD the FahrenheitCOMPUTE Celsius =(Fahrenheit 32)/1.8PRINT Celsiusstop

  • FlowchartSTARTCelsius =(Fahrenheit 32)/1.8Print CelsiusRead FahrenheitSTOP

  • Finding the sum of odd number between 1 to nAlgorithm Step1: StartStep2: Read the value of n and set sum=0,i=1 Step3: While (i
  • Pseudocode

    READ the value of n and set sum=0,i=1 WHILE (i

  • FlowchartStartsum=0,i=1sum=sum+ii=i+2Print sumstopRead nWhile i
  • Finding the sum of even number between 1 to nAlgorithm Step1: StartStep2: Read the value of n and set sum=0,i=0 Step3: While (i
  • Pseudocode

    READ the value of n and set sum=0,i=0 WHILE (i

  • FlowchartStartsum=0,i=0sum=sum+ii=i+2Print sumstopRead nWhile i
  • Conversion of Binary number to DecimalAlgorithm Step1: StartStep2: Read the value of n and set i = 0, sum = 0Step3: While n>0 dor=n%10sum=sum + r*pow(2,i)n=n/10i=i+1 else Goto step5Step4: Goto step 3Step5: print the value of sumStep6: Stop

  • Pseudocode

    READ the value of n and set i =0, sum=0WHILE (n>0) do r=n%10 sum=sum + r*pow(2,i) n=n/10 i=i+1ENDWHILERepeat the loop until condition failsWRITE sumstop

  • FlowchartStartsum=0,i=0Print sumstopRead nWhile n>0 r=n%10sum=sum + r*Pow(2,i)n=n/10i=i+1

  • Application software Packages

  • Application softwareSet of programs, which is used to perform some specific task.Example:Word processorSpreadsheet programDatabase program etc,.

  • MS-WordStarting MS-WordStart All Programs Microsoft Office Microsoft Office Word

  • Creating a New DocumentFile New (or) ctrl+N(or) clicking the new button

    Opening a DocumentFile Open (or) ctrl+O(or) clicking the open button

  • Saving a New DocumentFile Save (or) ctrl+S(or) clicking the save button

    Printing a DocumentFile Print (or) ctrl+P(or) clicking the open button

  • Moving the TextCtrl+X(or) clicking the cut button

    Copying the TextCtrl+P(or) clicking the copy button

  • Find and ReplaceFind & ReplaceEdit Find and Replace (or) Ctrl+F

  • Formatting the DocumentFormat Menu (Format Font)Font size, type, colour, Subscript, Superscript, Spacing,Text Effects etc,.Bullets and NumberingsChanging caseBorders and Shadings etc,.