3 CHAPTER INSIDE THIS CHAPTER 32 3.1. Problem 3.5. Data Flow Diagram (DFD) 3.2. Design Flow to Solve a Problem 3.6. Text Editor 3.3. Algorithms 3.7. VI Editor 3.4. Flow Chart Overview of Algorithm, Flowcharts and DFD 3. 3. 3. 3. 3.1. PR PR PR PR PROBLEM OBLEM OBLEM OBLEM OBLEM IMPORTANT NOTES Problems are obstacles or undesirable situations that prevent us from getting an objective. So there is thirst to solve the problem in order to get objective. We can classify the problems into categories : n Mathematical n Logical n Political n Social n Economical n Physical n Chemical n Engineering n Medical n Environmental DO YOU KNO DO YOU KNO DO YOU KNO DO YOU KNO DO YOU KNOW At present, we are always try to solve either Mathematical or Logical problems in every context of life.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
3CHAPTER
INSIDE THIS CHAPTER
32
3.1. Problem 3.5. Data Flow Diagram (DFD)3.2. Design Flow to Solve a Problem 3.6. Text Editor3.3. Algorithms 3.7. VI Editor3.4. Flow Chart
Problems are obstacles or undesirable situations that prevent us from gettingan objective. So there is thirst to solve the problem in order to get objective.
��������������� ��������������������������
� ��� �������
� ������
� �������
� �����
� ���������
� � �����
� � �����
� ���������
� ������
� ������������
DO YOU KNODO YOU KNODO YOU KNODO YOU KNODO YOU KNOWWWWW
At present, we are always tryto solve either Mathematicalor Logical problems in everycontext of life.
3.2.3.2.3.2.3.2.3.2. DESIGN FLDESIGN FLDESIGN FLDESIGN FLDESIGN FLOOOOOW TW TW TW TW TO SOLO SOLO SOLO SOLO SOLVE A PRVE A PRVE A PRVE A PRVE A PROBLEMOBLEMOBLEMOBLEMOBLEM
& ����������� ������"�� �"���'��
�����"���%
What are the things that you require to dothe design?
Step-by-step solution of problem in EnglishLanguage or in Engish- Program-Style.
Flow Chart is a modeling tool to describe our algorithm pictorially or graphically,this is easy to understand
DFD is a modeling tool, which contains some functional/process through whichdata flow from one location to another location
Whatever you write in algorithm, we have to just design it using any programlanguage like C, C++, Java, and Dotnet etc.
Assign the inputs, which is obtainedfrom user, to A & B
DESIGN IDEA
SPECIFIC ATIO N
ALG ORITHM S
FLOW CHART
DATA FLO W DIAG RAM
IMPLEMENTATIO N USING A NY LANG UAGE
DO YOU KNODO YOU KNODO YOU KNODO YOU KNODO YOU KNOWWWWW
Implementation of a problemusing any programming lan-guage is just weighted 20%of the complete project & theremaining 80% weightageuses the documentation parti.e. Algorithms, Flow-Charts,Data Flow Diagram.
DO YOU KNODO YOU KNODO YOU KNODO YOU KNODO YOU KNOWWWWW
Algorithm is used to calculatethe time & space, a programtakes for its execution andstorage respectively (i.e.running time).
set A <- {Enter first input} or set A := {Enter first input}
set B <- {Enter second input} or set B := {Enter second input}
3.3.3.3.3.3.3.3.3.3.11111..... CharCharCharCharCharactactactactacteriseriseriseriseristics of Algorithmstics of Algorithmstics of Algorithmstics of Algorithmstics of Algorithms
3.3.3.3.3.3.3.3.3.3.3.3.3.3.3. An ExAn ExAn ExAn ExAn Examamamamamplepleplepleple
�����������������������������������������
35OVERVIEW OF ALGORITHM, FLOW CHARTS AND DFD
��
������
ALALALALALGORITHM IN ENGLISH LANGUGORITHM IN ENGLISH LANGUGORITHM IN ENGLISH LANGUGORITHM IN ENGLISH LANGUGORITHM IN ENGLISH LANGUAAAAAGE SGE SGE SGE SGE STTTTTYLE FYLE FYLE FYLE FYLE FOR THE ABOR THE ABOR THE ABOR THE ABOR THE ABOOOOOVE PRVE PRVE PRVE PRVE PROBLEMOBLEMOBLEMOBLEMOBLEM
ALALALALALGORITHM IN ENGLISH PRGORITHM IN ENGLISH PRGORITHM IN ENGLISH PRGORITHM IN ENGLISH PRGORITHM IN ENGLISH PROGRAMMING SOGRAMMING SOGRAMMING SOGRAMMING SOGRAMMING STTTTTYLE FYLE FYLE FYLE FYLE FOR THE ABOR THE ABOR THE ABOR THE ABOR THE ABOOOOOVE PRVE PRVE PRVE PRVE PROBLEMOBLEMOBLEMOBLEMOBLEM
1. Set A ←←←←← 1
2. Do (step 3 & 4) while (A < 11)
3. Print A
4. A ←←←←← A + 1
5. Exit
IMPLEMENTIMPLEMENTIMPLEMENTIMPLEMENTIMPLEMENTAAAAATION OR C PRTION OR C PRTION OR C PRTION OR C PRTION OR C PROGRAM FOGRAM FOGRAM FOGRAM FOGRAM FOR THE ABOR THE ABOR THE ABOR THE ABOR THE ABOOOOOVE PRVE PRVE PRVE PRVE PROBLEMOBLEMOBLEMOBLEMOBLEM
3.3.5.3.3.5.3.3.5.3.3.5.3.3.5. TTTTTechniqechniqechniqechniqechniques used tues used tues used tues used tues used to Design an Algorithmo Design an Algorithmo Design an Algorithmo Design an Algorithmo Design an Algorithm
6.6.6.6.6. BrBrBrBrBrututututute Fe Fe Fe Fe Forororororce Algorithmce Algorithmce Algorithmce Algorithmce Algorithm& ��,�"��� *����� ������� � ������� ��� ����� ������������ ���� �������� � ��"� � �����
���������"���������������"���%
77777..... BrBrBrBrBranch and Boundanch and Boundanch and Boundanch and Boundanch and Bound& ��(����� ����������"����,���� �!�,�"���������� ��������������'�����"��"����
3.3.6.3.3.6.3.3.6.3.3.6.3.3.6. Some ExSome ExSome ExSome ExSome Examamamamamples tples tples tples tples to Wo Wo Wo Wo Writritritritrite Algorithmse Algorithmse Algorithmse Algorithmse Algorithms
Example 1. )�����������������������%�$���������∆∆∆∆∆��������������%��������*
Triangle (A, B, C)A: first side of the triangleB: second side of the triangleC: third side of the triangle
1. Set A ←←←←← {Enter first side}2. Set B ←←←←← {Enter second side}3. Set C ←←←←← {Enter third side}
4. If A = B C2 2+
5. Go to (11)
6. If B = A C2 2+
7. Go to (11)
8. If C = A B2 2+
9. Go to (11)10. Print “not forms a right angled triangle” & Exit11. Print “forms a right angled triangle” & Exit
Example 2. )������������������������+��������������,�������������%%�*
Evenodd (A)
A: A is the number to be checked weather it is even or odd
38 INTRODUCTION TO PROGRAMMING
1. Set A <- {Enter a number}
2. if ( A % 2 = 0) then
Print “A is Even number” & Exit.
3. Print “ A is Odd number” & Exit.
Example 3. )�����������������������%���������������-��������*
Smallest (A,B,C)
A: first number
B: second number
C: third number
1. Set A ←←←←← {Enter first number}
2. Set B ←←←←← {Enter second number}
3. Set C ←←←←← {Enter third number}
4. If (A < B & A < C) then
5. Print “A is smallest” & Exit.
6. If (B < C & B < A) then
7. Print “B is smallest” & Exit.
8. If (C < A & C < B) then
9. Print “C is smallest” & Exit.
Example 4. )���������������������$���$��������������������%���������*
This is a modeling tool to describe an algorithm pictorially or graphically,which is easy to understand.
3.4.3.4.3.4.3.4.3.4.11111..... AdvAdvAdvAdvAdvantantantantantages of Floages of Floages of Floages of Floages of Flow Charw Charw Charw Charw Chartststststs
3.4.2.3.4.2.3.4.2.3.4.2.3.4.2. Symbols Used in FloSymbols Used in FloSymbols Used in FloSymbols Used in FloSymbols Used in Flow Charw Charw Charw Charw Charttttt
"#��������% .��� /��%������$�������
�� =>(� ?���������������������
�� �(9(����=<9(� ?���������"�������"��"�%
��� 9��&()<�� ?����������������
��� +������,�� ?�������������
��)� ?�������� � ����� ����������
���������� �=))��&=9 ?�������-���� ��������������
DO YOU KNODO YOU KNODO YOU KNODO YOU KNODO YOU KNOWWWWW
Flow-Char t is used togenerate the sequence orflow of events in which problemis solved and represent theflow of events graphically.
40 INTRODUCTION TO PROGRAMMING
3.4.3.3.4.3.3.4.3.3.4.3.3.4.3. ExExExExExamamamamamples of Floples of Floples of Floples of Floples of Flow Charw Charw Charw Charw Chartststststs
Example 1. ���$�����$���������������$���������,
Solution.
STAR T
Input Two NumbersA AND B
C: = A + B
PRINT C
STOP
Fig. 3.1.
Example 2. ���$�������$�������������%�$���������∆∆∆∆∆��������������%�������*
Solution. STAR T
If A B C2 2= +
Print "fo rm s a rightangled tria ngle"
N O
If B A C2 2= +
If C A B2 2= +
N O
N O
ST O P
YE S
YE S
YE S
Fig. 3.2.
41OVERVIEW OF ALGORITHM, FLOW CHARTS AND DFD
��
������
Example 3. ���$�������$�������������%������������������-��������,
Solution. START
INPUT 3 num bera, b, c
If a > b
If b > c
Print c is sm allestPrint b is sm allest
STOP
If a > c
print a is sm allest
Yes
N o
Yes
N o
YesN o
Fig. 3.3.
Example 4. ���$�������$�������������%������������-���������*
3.5.3.5.3.5.3.5.3.5.11111..... SSSSSttttteps in Dateps in Dateps in Dateps in Dateps in Data Floa Floa Floa Floa Flow Analyw Analyw Analyw Analyw Analysississississis
DO YOU KNODO YOU KNODO YOU KNODO YOU KNODO YOU KNOWWWWWData Flow Diagram is used tocheck the flow of data i.e. howdata is stored in database orhow data is retrieved from thedatabase or how it is updated.
4. A Le4. A Le4. A Le4. A Le4. A Levvvvvel Datel Datel Datel Datel Data Floa Floa Floa Floa Flow Diagrw Diagrw Diagrw Diagrw Diagram fam fam fam fam for the Same Syor the Same Syor the Same Syor the Same Syor the Same Syssssstttttememememem
Custom er
Custom er Custom er
Enqu iry ProcessEnqu iry
1
ProcessEnqu iry
2
C us tom ersStoreD 2 Item
StoreD 2
ItemIn fo rmation
Item deta ils /ava ilab ility
Custom erDeta ils
O rd erStore
D 3
O rder
O rder D etails
Item s
Invoice
Fig. 3.16.
3.6.3.6.3.6.3.6.3.6. TEXT EDITTEXT EDITTEXT EDITTEXT EDITTEXT EDITOROROROROR
IMPORTANT NOTES
Text editor is a program that enables you to create and edit text files.
3.6.3.6.3.6.3.6.3.6.11111..... TTTTTypes of Types of Types of Types of Types of Teeeeext Editxt Editxt Editxt Editxt Editorororororsssss
(1)(1)(1)(1)(1) NNNNNoooootttttepad++ (used only in Wepad++ (used only in Wepad++ (used only in Wepad++ (used only in Wepad++ (used only in Windoindoindoindoindowwwwws opers opers opers opers operating syating syating syating syating syssssstttttem)em)em)em)em)
(2)(2)(2)(2)(2) Emacs (used in all platfEmacs (used in all platfEmacs (used in all platfEmacs (used in all platfEmacs (used in all platforororororms i.e. use anms i.e. use anms i.e. use anms i.e. use anms i.e. use any opery opery opery opery operatingatingatingatingatingsysysysysysssss tttttem)em)em)em)em)
DO YOU KNODO YOU KNODO YOU KNODO YOU KNODO YOU KNOWWWWW
Platform independent meansthat the editor is independenton the operating system thatthe system uses i.e. the editorcan be run either on windowsor Mac OS or Unix or Linux.
54 INTRODUCTION TO PROGRAMMING
(3)(3)(3)(3)(3) UltrUltrUltrUltrUltraEdit (used only in WaEdit (used only in WaEdit (used only in WaEdit (used only in WaEdit (used only in Windoindoindoindoindowwwwws opers opers opers opers operating syating syating syating syating syssssstttttem)em)em)em)em)
(4)(4)(4)(4)(4) TTTTTeeeeextMatxtMatxtMatxtMatxtMate (used only in Mac OSX opere (used only in Mac OSX opere (used only in Mac OSX opere (used only in Mac OSX opere (used only in Mac OSX operating syating syating syating syating syssssstttttem)em)em)em)em)
(5)(5)(5)(5)(5) Vim (used in all platfVim (used in all platfVim (used in all platfVim (used in all platfVim (used in all platforororororms)ms)ms)ms)ms)
(6)(6)(6)(6)(6) TTTTTeeeeextPxtPxtPxtPxtPad (used only in windoad (used only in windoad (used only in windoad (used only in windoad (used only in windowwwwws opers opers opers opers operating syating syating syating syating syssssstttttem)em)em)em)em)
3.73.73.73.73.7.2..2..2..2..2. HoHoHoHoHow tw tw tw tw to So So So So Stttttararararart the VI Tt the VI Tt the VI Tt the VI Tt the VI Teeeeext Editxt Editxt Editxt Editxt Editororororor
3.73.73.73.73.7.3..3..3..3..3. HoHoHoHoHow tw tw tw tw to Exit fro Exit fro Exit fro Exit fro Exit from VI Tom VI Tom VI Tom VI Tom VI Teeeeext Editxt Editxt Editxt Editxt Editororororor
3.73.73.73.73.7.4..4..4..4..4. TTTTTeeeeext Bufxt Bufxt Bufxt Bufxt Buffffffererererers used in VI Ts used in VI Ts used in VI Ts used in VI Ts used in VI Teeeeext Editxt Editxt Editxt Editxt Editororororor
3.73.73.73.73.7.5..5..5..5..5. Some SimSome SimSome SimSome SimSome Simple VI Tple VI Tple VI Tple VI Tple VI Teeeeext Editxt Editxt Editxt Editxt Editor Commandsor Commandsor Commandsor Commandsor Commands
3.73.73.73.73.7.6..6..6..6..6. ComComComComCompilation and Rpilation and Rpilation and Rpilation and Rpilation and Running a Vi tunning a Vi tunning a Vi tunning a Vi tunning a Vi teeeeext editxt editxt editxt editxt editor pror pror pror pror progrogrogrogrogramamamamam