107
UNIT - 3 PROBLEM SOLVING AND OFFICE AUTOMATION

Proble, Solving & Automation

Embed Size (px)

Citation preview

Page 1: Proble, Solving & Automation

UNIT - 3

PROBLEM SOLVING

AND

OFFICE AUTOMATION

Page 2: Proble, Solving & Automation

Program

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

Page 3: Proble, Solving & Automation

Problem Solving Steps

• Analyse 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.

Page 4: Proble, Solving & Automation

Program Development Cycle

Methodologies

• Program planning method

• Waterfall method etc,.

Page 5: Proble, Solving & Automation

Program planning methodSpecification

Review

Informal Design

Test & Debug

Coding

Formal Design

Maintaining

Page 6: Proble, Solving & Automation

• Specification review– collect the requirements– understand the requirements

• Informal Design– Identifies the major tasks– Identifies the subtasks

• Formal Design– It converts the informal design to some format

that can be understand by others.

Page 7: Proble, Solving & Automation

• Coding– It converts the Design into Programs.– It translate these programs to machine

language.

• Test & Debug– It use sample data to test whether it works

properly.– It also eliminate the errors.

Page 8: Proble, Solving & Automation

• Maintaining– It Modifies the programs if necessary.

Page 9: Proble, Solving & Automation

Waterfall method

Feasibility

Analysis

Maintenance

Testing

Impl

Design

Page 10: Proble, Solving & Automation

• Feasibility

– It determines whether it is possible to create the project or not.

– It also produce the plans and the estimates.

• Analysis– It get the requirements from the

customer.

– It analysis the requirements.

Page 11: Proble, Solving & Automation

• Design

– It is the process of designing how the requirements to be implemented.

• Implementation– It converts the designs into code.

– After coding it use language translators to compile the code.

Page 12: Proble, Solving & Automation

• Testing– Here the modules are integrated

together.– Then the project is tested and find

whether it meets the customer/user requirements.

• Maintenance– It make modifications based on the

customer feedbacks.

Page 13: Proble, Solving & Automation

Algorithm

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

Page 14: Proble, Solving & Automation

Characteristics

• The 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.

Page 15: Proble, Solving & Automation

Factors used to judge the algorithm

• Time

• Memory

• Accuracy

• Sequence etc,.

Page 16: Proble, Solving & Automation

Representations

• Flowcharts

• Normal English

• Pseudo code etc,.

Page 17: Proble, Solving & Automation

Example

• Addition of two numbers

Step1: Start

Step2: Read a, b

Step3: Add the value of a with b and store the result in c.

Step4: Display the value of c

Step5: Stop

Page 18: Proble, Solving & Automation

Flowcharts

• It is the pictorial representation of the algorithm.

Page 19: Proble, Solving & Automation

Flowchart Symbols

• Terminal symbol– It is used to represent the start, end of the

program logic.

• Input/Output– It is used for input or output.

• Process Symbol– It is used to represent the calculations, data

movements, initialization operations etc,.

Page 20: Proble, Solving & Automation

• Decision Symbol

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

• Flow lines– It is used to connect the symbols

• Connectors– It is used to connect the flow lines.

Page 21: Proble, Solving & Automation

Guidelines for preparing flowcharts

• It 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.

Page 22: Proble, Solving & Automation

• 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

Page 23: Proble, Solving & Automation

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

Page 24: Proble, Solving & Automation

Benefits of Flowcharts

• Makes Logic Clear

• Communication

• Effective Analysis

• Useful in coding

• Useful in Testing etc,.

Page 25: Proble, Solving & Automation

Limits of Flowcharts

• It is difficult to use flowcharts for large program

• Difficult to modify

• Cost etc,.

Page 26: Proble, Solving & Automation

Pseudocode

• Pseudo means imitates and code means instruction.

• It is formal design tool.

• It is also called Program Design Language.

Page 27: Proble, Solving & Automation

Keywords

• READ,GET

• PRINT,DISPLAY

• COMPUTE,CALCULATE

Page 28: Proble, Solving & Automation

Guideline for writing Pseudocode

• Steps should be understandable

• Capitalize the keyword.

• Indent to show hierarchy.

• End multiple line structure etc,.

Page 29: Proble, Solving & Automation

Example

READ a,b

C=a+b

WRITE C

stop

Page 30: Proble, Solving & Automation

Example

READ a,b

IF a>b

PRINT a is greater

ELSE

PRINT b is greater

ENDIF

stop

Page 31: Proble, Solving & Automation

Advantage & Disadvantage

• It can be easily modified

• It can be understood easily

• Compare to flowchart it is difficult to understand the program logic.

Page 32: Proble, Solving & Automation

Sequence control structureFlow chart Pseudocode

Process 1Process 2

Process n

Process 2

Process n

Process 1

Design Structures

Page 33: Proble, Solving & Automation

Sequence control structure• The instructions are computed in

sequence i.e. it performs instruction one after another.

• It uses top-down approach.

Design Structures

Page 34: Proble, Solving & Automation

Example

START

C=a+b

Print c

Read a,b

STOP

Page 35: Proble, Solving & Automation

SELECTION CONTROL STRUCTURE

• It is used for making decisions.

• It allows the program to make a choice from alternative paths.

• IF …THEN

• IF …THEN… ELSE

• CASE etc.,

Page 36: Proble, Solving & Automation

IF…THEN

Pseudocode Flow chartIF condition THEN

process 1

.

.END IF

.

.

If condition

NO

YES

Process 1

Page 37: Proble, Solving & Automation

ExampleStart

Read a

If a>0

Print a is Positive

Stop

no

yes

Page 38: Proble, Solving & Automation

IF…THEN…ELSE

Pseudocode Flowchart

IF condition THENprocess 1

.

.ELSE

process 2..

END IF..

If condition

YES NO

Process 1 Process 2

Page 39: Proble, Solving & Automation

ExampleStart

Read a,b

If a>b

Print a is GreaterPrint b is Greater

Stop

no

yes

Page 40: Proble, Solving & Automation

CASE structurePseudocode Flow chart

.

.CASE TypeCase Type-1:

Process 1Case Type-2:

Process 2..

Case Type-n:Process n..

END CASE

Type 1

Type 2

Type 3

Process 1

Process 2

Process 3

no

no

no

yes

yes

yes

Page 41: Proble, Solving & Automation

start

stop

Read m1,m2,m3

Avg=(m1+m2+m3)/3

If Avg>=60

If Avg>=50

If Avg>=35

Fail

Print First Class

Print Second Class

Print Third Class

Example: Finding the Grade

Page 42: Proble, Solving & Automation

Looping control structure

• It is used to execute some instructions several time based on some condition.

• WHILE loop

• Do…WHILE loop etc.,

Page 43: Proble, Solving & Automation

WHILE Loop

Pseudocode Flow chart.

.WHILE condition

.

.Body of the loop

.

.END WHILE

Body of The loop

conditionno

yes

Page 44: Proble, Solving & Automation

ExampleStart

Num=0

Num=Num+1

Print Num

whileNum<5

stop

no

yes

Page 45: Proble, Solving & Automation

DO…WHILE Loop

Pseudocode Flow chartDO

.

.Body of the loop

.

.WHILE condition

.

.

END WHILE

Body of The loop

condition

no

yes

Page 46: Proble, Solving & Automation

ExampleStart

Num=0

Num=Num+1

Print Num

whileNum<5

stop

no

yes

Page 47: Proble, Solving & Automation

Example: Finding the area of a circle

Algorithm

Step1: Start

Step2: Read the value of r

Step3: Calculate area = 3.14*r*r

Step4: Print area

Step5: Stop

Page 48: Proble, Solving & Automation

Pseudocode

Set area

READ the r

COMPUTE area=3.14*r*r

PRINT area

stop

Page 49: Proble, Solving & Automation

Flowchart

START

area=3.14*r*r

Print area

Read r

STOP

Page 50: Proble, Solving & Automation

Find the largest among three Numbers

Algorithm Step1: StartStep2: Read the value of a, b, cStep3: IF (a>b) and (a>c) THEN

print a is largest ELSE IF (b>c) THEN

print b is largest ELSE

print c is largestStep4: Stop

Page 51: Proble, Solving & Automation

Pseudocode

READ a, b, cIF (a>b) and (a>c) THEN

WRITE a is largestELSE IF (b>c) THEN

WRITE b is largestELSE

WRITE c is largestENDIFstop

Page 52: Proble, Solving & Automation

Flowchart

START

Print b Is largest

Read a,b,c

stop

If (a>b) and

(a>c)

If b>c

Print a Is largest

Print c Is largest

no

yes

yes

no

Page 53: Proble, Solving & Automation
Page 54: Proble, Solving & Automation

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

roots

root1(-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

Page 55: Proble, Solving & Automation

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)ELSE

Roots are imaginaryEND IFWRITE root1,root2Stop

Page 56: Proble, Solving & Automation

Flow chartStart

Stop

D=b*b-4*a*c

Root1=[-b+sqrt(D)]/(2*a)Root2=[-b+sqrt(D)]/(2*a)

Read a,b,c

Print root1,root2

If D>=0no

yes

Printroots are imaginary

Page 57: Proble, Solving & Automation
Page 58: Proble, Solving & Automation

Swapping two variables

Algorithm Step1: StartStep2: Read the value of a, bStep3: c = a

a = b b = c

Step4: Print the value of a and bStep5: Stop

Page 59: Proble, Solving & Automation

Pseudocode

READ the value of a, bTo swap use

c = aa = bb = c

WRITE a, bstop

Page 60: Proble, Solving & Automation

FlowchartSTART

c = aa = bb = c

Print a, b

Read a, b

STOP

Page 61: Proble, Solving & Automation

Swapping two variables without using another variable

Algorithm 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

Page 62: Proble, Solving & Automation

Pseudocode

READ the value of a, bTo swap use

a = a + b b = a - b a = a - b

WRITE a, bstop

Page 63: Proble, Solving & Automation

FlowchartSTART

a = a + bb = a - ba = a - b

Print a, b

Read a, b

STOP

Page 64: Proble, Solving & Automation

Finding the year is leap year or not

Algorithm 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

Page 65: Proble, Solving & Automation

Pseudocode

READ year

IF year % 4 ==0 THEN

WRITE It is a Leap year

ELSE

WRITE It is not a Leap year

ENDIF

stop

Page 66: Proble, Solving & Automation

FlowchartStart

Read year

year % 4 ==0

Print It is a Leap year Print It is not a

Leap year

Stop

no

yes

Page 67: Proble, Solving & Automation

Finding the Factorial

Algorithm Step1: StartStep2: Read the value of n and set i =1Step3: While i <= n do

fact =fact * i i = i + 1 else Goto step5

Step4: Goto step 3Step5: print the value of factStep6: Stop

Page 68: Proble, Solving & Automation

Pseudocode

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

fact =fact * i i = i + 1

ENDWHILERepeat the loop until condition failsWRITE factstop

Page 69: Proble, Solving & Automation

FlowchartStart

Read ni = 1

fact=fact * ii=i+1

Print fact

while

i<=n

stop

no

yes

Page 70: Proble, Solving & Automation

Finding the Sum of the digits

Algorithm Step1: StartStep2: Read the value of n and set i = 0, sum = 0Step3: While n>0 do

r=n%10sum=sum + rn=n/10

else Goto step5Step4: Goto step 3Step5: print the value of sumStep6: Stop

Page 71: Proble, Solving & Automation

Pseudocode

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

r=n%10 sum=sum + r n=n/10

ENDWHILERepeat the loop until condition failsWRITE sumstop

Page 72: Proble, Solving & Automation

Flowchart Start

r = 0,sum=0

r=n%10sum=sum + r

n=n/10

Print sum

while

n>0

stop

no

yes

Read n

Page 73: Proble, Solving & Automation

Finding the Reverse of a Number

Algorithm Step1: StartStep2: Read the value of n and set i = 0, sum = 0Step3: While n>0 do

r=n%10sum=sum *10 + rn=n/10

else Goto step5Step4: Goto step 3Step5: print the value of sumStep6: Stop

Page 74: Proble, Solving & Automation

Pseudocode

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

r=n%10 sum=sum *10 + r n=n/10

ENDWHILERepeat the loop until condition failsWRITE sumstop

Page 75: Proble, Solving & Automation

Flowchart Start

r = 0,sum=0

r=n%10sum=sum *10 + r

n=n/10

Print sum

while

n>0

stop

no

yes

Read n

Page 76: Proble, Solving & Automation

Armstrong Number

Example: 153

13 +53 + 33 =153

Page 77: Proble, Solving & Automation

Finding an Armstrong NumberAlgorithm Step1: StartStep2: Read the value of n and set a = n, sum = 0Step3: While n>0 do

r=n%10sum=sum + r*r*rn=n/10

else Goto step5Step4: Goto step 3Step5: If a = sum then

Print Armstrong Number Else

Print It is Not an Armstrong Number Endif

Step6: Stop

Page 78: Proble, Solving & Automation

PseudocodeREAD the value of n and set a =n, sum=0WHILE (n>0) do

r=n%10 sum=sum + r*r*r n=n/10

ENDWHILERepeat the loop until condition failsIF a=sum THEN

WRITE Armstrong NumberELSE

WRITE It is not an Armstrong NumberENDIFstop

Page 79: Proble, Solving & Automation

Flowchart Start

a = n,sum=0

r=n%10sum=sum + r*r*r

n=n/10

Print Armstrong No

while

n>0

stop

noyes

Read n

if

a=sumPrint It is Not an Armstrong No

Page 80: Proble, Solving & Automation

Fibonacci seriesExample:

0 1 1 2 3 5 8 11….

Page 81: Proble, Solving & Automation

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

f=f1+f2 f1=f2 f2=f Print f else Goto step5

Step4: Goto step 3Step5: Stop

Page 82: Proble, Solving & Automation

Pseudocode

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

f=f1+f2 f1=f2 f2=f

WRITE fENDWHILERepeat the loop until condition failsstop

Page 83: Proble, Solving & Automation

Flowchart Start

f=0,f1= -1,f2=1

f=f1+f2f1=f2f2=f

Print f

while

f<n

stop

no

yes

Read n

Page 84: Proble, Solving & Automation

Conversion of Celsius to Fahrenheit

Algorithm

Step1: Start

Step2: Read the value of Celsius

Step3: Fahrenheit = (1.8* Celsius) + 32

Step4: Print Fahrenheit

Step5: Stop

Page 85: Proble, Solving & Automation

Pseudocode

Set Fahrenheit

READ the Celsius

COMPUTE Fahrenheit = (1.8* Celsius) + 32

PRINT Fahrenheit

stop

Page 86: Proble, Solving & Automation

Flowchart

START

Fahrenheit = (1.8* Celsius) + 32

Print Fahrenheit

Read Celsius

STOP

Page 87: Proble, Solving & Automation

Conversion of Fahrenheit to Celsius

Algorithm

Step1: Start

Step2: Read the value of Fahrenheit

Step3:Calculate Celsius =(Fahrenheit – 32)/1.8

Step4: Print Celsius

Step5: Stop

Page 88: Proble, Solving & Automation

Pseudocode

Set Celsius

READ the Fahrenheit

COMPUTE Celsius =(Fahrenheit – 32)/1.8

PRINT Celsius

stop

Page 89: Proble, Solving & Automation

Flowchart

START

Celsius =(Fahrenheit – 32)/1.8

Print Celsius

Read Fahrenheit

STOP

Page 90: Proble, Solving & Automation

Finding the sum of odd number between 1 to n

Algorithm Step1: StartStep2: Read the value of n and set sum=0,i=1 Step3: While (i<=n) do

sum=sum+i i=i+2 else Goto step5

Step4: Goto step 3Step5: Print sumStep6: Stop

Page 91: Proble, Solving & Automation

Pseudocode

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

sum=sum+i i=i+2

ENDWHILERepeat the loop until condition failsWRITE sumstop

Page 92: Proble, Solving & Automation

Flowchart Start

sum=0,i=1

sum=sum+ii=i+2

Print sum

stop

Read n

While i<=n

Page 93: Proble, Solving & Automation

Finding the sum of even number between 1 to n

Algorithm Step1: StartStep2: Read the value of n and set sum=0,i=0 Step3: While (i<=n) do

sum=sum+i i=i+2 else Goto step 5

Step4: Goto step 3Step5: Print sumStep6: Stop

Page 94: Proble, Solving & Automation

Pseudocode

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

sum=sum+i i=i+2

ENDWHILERepeat the loop until condition failsWRITE sumstop

Page 95: Proble, Solving & Automation

Flowchart Start

sum=0,i=0

sum=sum+ii=i+2

Print sum

stop

Read n

While i<=n

Page 96: Proble, Solving & Automation

Conversion of Binary number to Decimal

Algorithm Step1: StartStep2: Read the value of n and set i = 0, sum = 0Step3: While n>0 do

r=n%10sum=sum + r*pow(2,i)n=n/10i=i+1

else Goto step5Step4: Goto step 3Step5: print the value of sumStep6: Stop

Page 97: Proble, Solving & Automation

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+1

ENDWHILERepeat the loop until condition failsWRITE sumstop

Page 98: Proble, Solving & Automation

Flowchart Start

sum=0,i=0

Print sum

stop

Read n

While n>0

r=n%10sum=sum + r*Pow(2,i)

n=n/10i=i+1

Page 99: Proble, Solving & Automation

Application software Packages

Page 100: Proble, Solving & Automation

Application software

• Set of programs, which is used to perform some specific task.

• Example:• Word processor• Spreadsheet program• Database program etc,.

Page 101: Proble, Solving & Automation

MS-Word

• Starting MS-Word

Start All Programs Microsoft Office Microsoft Office Word

Page 102: Proble, Solving & Automation

• Creating a New Document

File New (or) ctrl+N

(or) clicking the new button

• Opening a Document

File Open (or) ctrl+O

(or) clicking the open button

Page 103: Proble, Solving & Automation

• Saving a New Document

File Save (or) ctrl+S

(or) clicking the save button

• Printing a Document

File Print (or) ctrl+P

(or) clicking the open button

Page 104: Proble, Solving & Automation

• Moving the Text

Ctrl+X

(or) clicking the cut button

• Copying the Text

Ctrl+P

(or) clicking the copy button

Page 105: Proble, Solving & Automation

Find and Replace

• Find & Replace

Edit Find and Replace (or) Ctrl+F

Page 106: Proble, Solving & Automation

Formatting the Document

• Format Menu (Format Font)

– Font size, type, colour, Subscript, Superscript, Spacing,Text Effects etc,.

– Bullets and Numberings

– Changing case

– Borders and Shadings etc,.

Page 107: Proble, Solving & Automation