Tuesday, November 27, 2007

Chapter 1, Lesson 6

Welcome to Beginners Programming.

However you think about it, our life is like a program, we have a pattern in which we should follow each and everyday. Some path that we should take whenever we face life’s choices, but then again, we still follow the program whichever path we take. No, its not the same pattern but it resembles what was. Let me show you a flowchart, just to let you see what I am trying to imply.



As you can see, you are trapped in a pattern which you cannot deny. Isn’t that what you are doing? Or if you are a student, you would follow this flow:



But it looks the same, the flow is the same. Oh you’ve noticed eh? The routine is different but the pattern is the same. Think about it, we are all locked into a flow, whatever pattern it may be, but it goes around and around everyday. Take this example:



Can we change it? Maybe. Can we escape the routine? Hmm we could, but it will still be another routine. Can we break the routine? I don’t know. Ask the experts about this. Now I’m pulling you back to our pattern, the problem solving and flowchart making.

Our lesson is to create a complex flowchart, but of course we need a problem so it will be more specific.

Problem 1:
Input 3 numbers and draw a flowchart that would determine which number is greater, and display the number on the screen.

Variables needed:
1. A, B, C

What does the problem want?
1. Determine the larger value
2. Display the larger value on the screen.

Flowchart



Yep, its like building a house. Can you follow the flow? Let us trace the flowchart.

Possible 1:

A=8, B=5 and C=3

1. it first get data from keyboard
2. then it asks if A > B (8 > 5)
3. true, it asks if A > C (8 > 3)
4. true, it prints the value of A (8) on the screen

Possible 2:

A=5, B=10 and C=3

1. it first get data from keyboard
2. then it asks if A > B (5 > 10)
3. false, it asks if B > C (10 > 3)
4. true, it prints the value of B (10) on the screen

Possible 3:

A=8, B=5 and C=18

1. it first get data from keyboard
2. then it asks if A > B (8 > 5)
3. true, it asks if A > C (8 > 18)
4. false, it asks if B > C (5 > 18)
5. false, it prints the value of C (18) on the screen

Possible 4:

A=5, B=10 and C=11

1. it first get data from keyboard
2. then it asks if A > B (5 > 10)
3. false, it asks if B > C (10 > 11)
4. false, it prints the value of C (11) on the screen

So that’s about it. We have seen how our flow of logic makes it through each possibility. But what if they have the same value? Yes what about it? Then we create a new flowchart to satisfy the need.

Revised Flowchart



Take note of the red colors, that’s the changes I made to satisfy the problem when one or more inputs are equal.

What can you get out of making a flowchart?

1. Communicate: Flowcharts are better way of communicating the logic of a system.
2. Analyze Effectively: Problem can be analyzed in more effective way by following the flow.
3. Good documentation: Flowcharts serve as a good program documentation, which is needed for various purposes.
4. Easy coding: The flowcharts act as a guide or blueprint during the systems analysis and program development phase.
5. Problem Identification: The flowchart helps in identifying the problem as it progress.
6. Easy Maintenance: The maintenance of operating program becomes easy with the help of flowchart. It helps the programmer to put efforts more efficiently on that part

What the limitations of using the flowchart?

1. Complex logic: Sometimes, the program logic is quite complicated. In that case, flowchart becomes complex and clumsy.
2. Alterations and Modifications: If alterations are required the flowchart may require re-drawing completely.

I guess that’s it for now. See you in our next lesson.

-End of lesson 6 Beginners Programming

No comments: