Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Flowchart I

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 27

 Computer is a machine.

 To
solve any problem (sum of two
numbers or any complex problem),
Computer can’t think its own to solve it.

 Butif we give instructions, computer will


follow and it will solve the problem.
 So
to solve any problem[sum of two
numbers (or) any complex problem] by
computer, we need to give instructions.

 Algorithms: sequence of
steps(instructions) for solving a given
problem.
Algorithm to find area of circle:
Step 1: Start Input
Step 2: Get the value of r Operation
Step 3: Calculate Area=Pi*r*r
Step 4: Display Area
Step 5: End
Processing
Output
Variable Operation
Here r,Area, and Pi
are called as
Algorithm to find sum of two numbers
1. Start
2. Get two numbers a,b
3. Calculate sum=a+b 1. Find
4. Display sum
operations in
this algorithm
5. Stop
2. Find
Variables in
this algorithm
Flow chart: Pictorial or Graphical
representation of algorithm.
Algorithm to find area of circle:
Step 1: Start
Step 2: Get the value of r
Step 3: Calculate Area=Pi*r*r
Step 4: Display Area
Step 5: End
1. Start
2. Get the value of a
3. Get the value of b
4. Calculate sum=a+b
5. Display sum
6. Stop
Question:
 Draw a flowchart to add 6 subject marks of
Mr.X and Find average marks of Mr.X.
Algorithm:
1. Start
2. Get the value of m1
3. Get the value of m2
4. Get the value of m3
5. Get the value of m4
6. Get the value of m5
7. Get the value of m6
8. Calculate
total=m1+m2+m3+m4+m5+m6
9. Calculate average=total/6
10. Display total
11.Display average
 Write an algorithm and draw a flowchart
that will calculate the roots of a quadratic
equation.
Hint:
Quadratic Equation: ax2+bx+c=0
Formula:
x1=(-b+d)/2a
X2=(-b-d)/2a
Where d=sqrt(b2-4ac)
Step1 : Start.
Step2: Get A.
Step3: Get B.
Step4: If A>B then goto step step5 otherwise goto step6.
Step5: Display A, then goto step 7
Step6: Display B, then goto step 7.
Step7: Stop
 Step 1: Start
 Step 2: Get A
 Step 3: Get B
 Step 4: If A>B then goto step 5 other wise
goto step6.
• Step 5: Diplay A, then goto 9
• Step 6: If B>A then goto Step 7 otherwise goto step8.
 Step 7: Display B, then goto 9
 Step 8: Display A equals to B then goto step9
 Step 9: Stop
1.Start
2. Display 10 1.Start
3. Display 11 2. Assign i=10
4. Display 12 3. If i>=20 then go to step 6
5. Display 13 otherwise go to step 4.
4. Display i
6. Display 14 5. i=i+1
. 6. Stop
.
.
.
.
.
12. Display 20
13. stop
Algorithm
1. Start
2. Assign i = 1 , Sum = 0
3. if ( i >= 10 ) go to step 7, otherwise go to step 4.
4. Sum = Sum + i
5. i = i + 1
6. go to 3
7. Display the value of Sum
8. Stop
Note:
Algorithm Flowchart for this
1. Start algorithm is
discussed in class.
2. Assign i = 1 , Sum = 0 Refer your class
note.
3. Get n
3. if ( i >= n ) go to step 7, otherwise go to step 4.
4. Sum = Sum + i
5. i = i + 1
6. go to 3
7. Display the value of Sum
8. Stop
Note:
Algorithm Flowchart for this
1. Start algorithm is
discussed in class.
2. Assign i = 1 , Fact = 1 Refer your class
note.
3. Get n
3. if ( i >= n ) go to step 7, otherwise go to step 4.
4. Fact = Fact * i
5. i = i + 1
6. go to 3
7. Display the value of Fact
8. Stop
Note:
Algorithm Flowchart for this
1. Start algorithm is
discussed in class.
2. Assign i = 1 , Sum = 0 Refer your class
note.
3. Get n
3. if ( i >= n ) go to step 7, otherwise go to step 4.
4. Sum = Sum + i
5. i = i + 2
6. go to 3
7. Display the value of Sum
8. Stop
Algorithm
1. Start
2. Assign count = 0
3. Get n
3. if ( n<1) go to step 7,
otherwise go to step 4.
4. n=n/10
5. count=count +1
6. go to 3
7. Display the value of
count
8. Stop
Activity:
Write an algorithm
To find given
number is
prime or not

You might also like