SlideShare a Scribd company logo
1 of 30
CS1101
Introduction toComputer Programming and
Data Structures
Dr. B Ramachandra Reddy
Outline
• Algorithm
• Flow Charts
• Pseudo Code
Program Planning
 To write a correct program, a programmer must write each and every
instruction in the correct sequence
 Logic (instruction sequence) of a program can be very complex
 Hence, programs must be planned before they are written to ensure
program instructions are:
 Appropriate for the problem
 In the correct sequence
Algorithm
 Refers to the logic of a program and a step-by-step description of how to
arrive at the solution of a given problem.
 In order to qualify as an algorithm, a sequence of instructions must
have following characteristics:
 Each and every instruction should be precise and unambiguous
 Each instruction should be such that it can be performed in a finite time
 One or more instructions should not be repeated infinitely. This ensures that the
algorithm will ultimately terminate
 After performing the instructions, that is after the algorithm terminates, the
desired results must be obtained
SampleAlgorithm (Example 1)
• There are 50 students in a class who appeared in their
final examination. Their mark sheets have been given to
you.
• The division column of the mark sheet contains the
division (FIRST, SECOND, THIRD or FAIL) obtained by the
student.
• Write an algorithm to calculate and print the total
number of students who passed in FIRST division.
SampleAlgorithm (Example 1)
Step 1: Initialize Total_First_Division and
Total_Marksheets_Checked to zero.
Step 2: Take the mark sheet of the next student.
Step 3: Check the division column of the mark sheet to see if it is
FIRST, if no, go to Step 5.
Step 4: Add 1 to Total_First_Division.
Step 5: Add 1 to Total_Marksheets_Checked.
Step 6: Is Total_Marksheets_Checked = 50, if no, go to Step 2.
Step 7: Print Total_First_Division.
Step 8: Stop.
Representation ofAlgorithms
 As flowcharts
 As pseudocodes
Flowchart
 Flowchart is a pictorial representation of an algorithm
 Uses symbols (boxes of different shapes) that have
standardized meanings to denote different types of
instructions
 Actual instructions are written within the boxes
 Boxes are connected by solid lines having arrow marks
to indicate the exact sequence in which the instructions
are to be executed
 Process of drawing a flowchart for an algorithm is called
flowcharting
Basic FlowchartSymbols
Examples of Decision Symbol
Is I = 10?
No
Yes
(a) A two-way branch decision. (b) A three-way branch decision.
A > B
A = B
A < B Compare
A & B
Examples of Decision Symbol
I = ?
(c) A multiple-way branch decision.
= 0 = 1 = 2 = 3 = 4 = 5 = Other
Sample Flowchart
Sample Flowchart
Pseudocode
 A program planning tool where program logic is written in
an ordinary natural language using a structure that
resembles computer instructions
 “ Pseudo” means imitation or false and “ Code” refers to
the instructions written in a programming language.
Hence, pseudocode is an imitation of actual computer
instructions
 Because it emphasizes the design of the program,
pseudocode is also called Program Design Language
(PDL)
Basic Logic (Control) Structures
• Any program logic can be expressed by using only
following three simple logic structures:
1. Sequence logic,
2. Selection logic, and
3. Iteration (or looping) logic
• Programs structured by using only these three logic
structures are called structured programs, and the
technique of writing such programs is known as structured
programming
Pseudocode
• read/get – indicates a user will be inputting something
• display/print/show – indicates that an output will appear on the screen
• SET, INIT: To initialize values
• Expressions
• ←Assignment (like = inC)
• = Equality testing (like = = inC)
• n2 superscripts and other mathematical formatting allowed
• Method call
• var.method (arg [, arg…])
• Return value
• return expression
SequenceLogic
Process 1
(b) Pseudocode
Process 2
Process 1
Process 2
(a) Flowchart
Selection Logic
• Also known as decision logic, it is used for making decisions
• Three popularly used selection logic structures are
1. IF…THEN…ELSE
2. IF…THEN
3. CASE
Selection Logic (IF…THEN…ELSE Structure)
THEN
ELSE
Process 1
Process 2
IF Condition
ENDIF
(b) Pseudocode
THEN
Process 1
ELSE
Process 2
Yes No
(a) Flowchart
IF (condition)
Selection Logic (IF…THEN Structure)
(b) Pseudocode
THEN
ENDIF
IF Condition
Process 1
THEN
Process 1
Yes No
(a) Flowchart
IF (condition)
Selection Logic (CASE Structure)
(b) Pseudocode
CASE Type
Case Type 1:
Case Type 2:
Process 1
Process 2
ENDCASE
Case Type n: Process n
Type 1
Type n
Process 2
Process 1
Process n
Yes
Yes
Yes
No
Type 2
No
No
(a) Flowchart
Iteration (or Looping) Logic
 Used to produce loops in program logic when one or more instructions may
be executed several times depending on some conditions
 Two popularly used iteration logic structures are
1. DO…WHILE
2. REPEAT…UNTIL
Iteration (or Looping) Logic
(DO…WHILE Structure)
(b) Pseudocode
DO WHILE Condition
Process 1
Process n
ENDDO
Process 1
False
(a) Flowchart
Process n
True
Condition?
Block
Iteration (or Looping) Logic
(REPEAT…UNTIL Structure)
(b) Pseudocode
REPEAT
Process 1
Process n
UNTIL Condition
Process 1
Process n
True
(a) Flowchart
False
Condition?
SampleAlgorithm
SampleAlgorithm
Flowchart Pseudocode
Start/End Begin/End
Input/output Read: read x,y
Print: Print y
Process Computation: X<-y+6
Decision If/if-lse/case/while/
do-while/for
Connector Not Applicable
Predefined Process Not Applicable
FlowchartVs Pseudo code
FlowchartVs Pseudo code
• Flowchart Advantages
• Standard
• Visual
• Flowchart Disadvantages
• Hard to modify
• Structured design elements not
implemented
• Special software required
• Pseudocode Advantages
• Easily modified
• Implements structured concepts
• Done easy on Word Processor
• Pseudocode Disadvantages
• Not Visual
• Not accepted standard, varies
from company to company
Assignments
• Write a pseudo code and flowchart to find the given number is prime
or not?
• Write a pseudo code and flowchart to generate the Fibonacci series
upto n numbers.
• Write a pseudo code and flowchart to check the given number is
palindrome or not?

More Related Content

Similar to Algorithms for c nit jamshedpur first year

Code Analysis-run time error prediction
Code Analysis-run time error predictionCode Analysis-run time error prediction
Code Analysis-run time error predictionNIKHIL NAWATHE
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptxTadiwaMawere
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptReshuReshma8
 
final Unit 1-1.pdf
final Unit 1-1.pdffinal Unit 1-1.pdf
final Unit 1-1.pdfprakashvs7
 
Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software developmentHattori Sidek
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and reviewAbdullah Al-hazmy
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowchartsmoazwinner
 
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptxLec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptxAbdelrahmanRagab36
 
Cs1123 2 comp_prog
Cs1123 2 comp_progCs1123 2 comp_prog
Cs1123 2 comp_progTAlha MAlik
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#Hawkman Academy
 
AlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfSusieMaestre1
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptxssuser586772
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithmmshoaib15
 

Similar to Algorithms for c nit jamshedpur first year (20)

chapter 1
chapter 1chapter 1
chapter 1
 
Code Analysis-run time error prediction
Code Analysis-run time error predictionCode Analysis-run time error prediction
Code Analysis-run time error prediction
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
 
final Unit 1-1.pdf
final Unit 1-1.pdffinal Unit 1-1.pdf
final Unit 1-1.pdf
 
Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software development
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and review
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowcharts
 
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptxLec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
 
UNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.pptUNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.ppt
 
Cs1123 2 comp_prog
Cs1123 2 comp_progCs1123 2 comp_prog
Cs1123 2 comp_prog
 
Introduction to algorithms
Introduction to algorithmsIntroduction to algorithms
Introduction to algorithms
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
AlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdf
 
algorithm
algorithmalgorithm
algorithm
 
01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx01 Introduction to analysis of Algorithms.pptx
01 Introduction to analysis of Algorithms.pptx
 
Algorithm Design and Analysis
Algorithm Design and AnalysisAlgorithm Design and Analysis
Algorithm Design and Analysis
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 

Recently uploaded

Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 

Recently uploaded (20)

Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

Algorithms for c nit jamshedpur first year

  • 1. CS1101 Introduction toComputer Programming and Data Structures Dr. B Ramachandra Reddy
  • 2. Outline • Algorithm • Flow Charts • Pseudo Code
  • 3. Program Planning  To write a correct program, a programmer must write each and every instruction in the correct sequence  Logic (instruction sequence) of a program can be very complex  Hence, programs must be planned before they are written to ensure program instructions are:  Appropriate for the problem  In the correct sequence
  • 4. Algorithm  Refers to the logic of a program and a step-by-step description of how to arrive at the solution of a given problem.  In order to qualify as an algorithm, a sequence of instructions must have following characteristics:  Each and every instruction should be precise and unambiguous  Each instruction should be such that it can be performed in a finite time  One or more instructions should not be repeated infinitely. This ensures that the algorithm will ultimately terminate  After performing the instructions, that is after the algorithm terminates, the desired results must be obtained
  • 5. SampleAlgorithm (Example 1) • There are 50 students in a class who appeared in their final examination. Their mark sheets have been given to you. • The division column of the mark sheet contains the division (FIRST, SECOND, THIRD or FAIL) obtained by the student. • Write an algorithm to calculate and print the total number of students who passed in FIRST division.
  • 6. SampleAlgorithm (Example 1) Step 1: Initialize Total_First_Division and Total_Marksheets_Checked to zero. Step 2: Take the mark sheet of the next student. Step 3: Check the division column of the mark sheet to see if it is FIRST, if no, go to Step 5. Step 4: Add 1 to Total_First_Division. Step 5: Add 1 to Total_Marksheets_Checked. Step 6: Is Total_Marksheets_Checked = 50, if no, go to Step 2. Step 7: Print Total_First_Division. Step 8: Stop.
  • 7. Representation ofAlgorithms  As flowcharts  As pseudocodes
  • 8. Flowchart  Flowchart is a pictorial representation of an algorithm  Uses symbols (boxes of different shapes) that have standardized meanings to denote different types of instructions  Actual instructions are written within the boxes  Boxes are connected by solid lines having arrow marks to indicate the exact sequence in which the instructions are to be executed  Process of drawing a flowchart for an algorithm is called flowcharting
  • 10. Examples of Decision Symbol Is I = 10? No Yes (a) A two-way branch decision. (b) A three-way branch decision. A > B A = B A < B Compare A & B
  • 11. Examples of Decision Symbol I = ? (c) A multiple-way branch decision. = 0 = 1 = 2 = 3 = 4 = 5 = Other
  • 14. Pseudocode  A program planning tool where program logic is written in an ordinary natural language using a structure that resembles computer instructions  “ Pseudo” means imitation or false and “ Code” refers to the instructions written in a programming language. Hence, pseudocode is an imitation of actual computer instructions  Because it emphasizes the design of the program, pseudocode is also called Program Design Language (PDL)
  • 15. Basic Logic (Control) Structures • Any program logic can be expressed by using only following three simple logic structures: 1. Sequence logic, 2. Selection logic, and 3. Iteration (or looping) logic • Programs structured by using only these three logic structures are called structured programs, and the technique of writing such programs is known as structured programming
  • 16. Pseudocode • read/get – indicates a user will be inputting something • display/print/show – indicates that an output will appear on the screen • SET, INIT: To initialize values • Expressions • ←Assignment (like = inC) • = Equality testing (like = = inC) • n2 superscripts and other mathematical formatting allowed • Method call • var.method (arg [, arg…]) • Return value • return expression
  • 17. SequenceLogic Process 1 (b) Pseudocode Process 2 Process 1 Process 2 (a) Flowchart
  • 18. Selection Logic • Also known as decision logic, it is used for making decisions • Three popularly used selection logic structures are 1. IF…THEN…ELSE 2. IF…THEN 3. CASE
  • 19. Selection Logic (IF…THEN…ELSE Structure) THEN ELSE Process 1 Process 2 IF Condition ENDIF (b) Pseudocode THEN Process 1 ELSE Process 2 Yes No (a) Flowchart IF (condition)
  • 20. Selection Logic (IF…THEN Structure) (b) Pseudocode THEN ENDIF IF Condition Process 1 THEN Process 1 Yes No (a) Flowchart IF (condition)
  • 21. Selection Logic (CASE Structure) (b) Pseudocode CASE Type Case Type 1: Case Type 2: Process 1 Process 2 ENDCASE Case Type n: Process n Type 1 Type n Process 2 Process 1 Process n Yes Yes Yes No Type 2 No No (a) Flowchart
  • 22. Iteration (or Looping) Logic  Used to produce loops in program logic when one or more instructions may be executed several times depending on some conditions  Two popularly used iteration logic structures are 1. DO…WHILE 2. REPEAT…UNTIL
  • 23. Iteration (or Looping) Logic (DO…WHILE Structure) (b) Pseudocode DO WHILE Condition Process 1 Process n ENDDO Process 1 False (a) Flowchart Process n True Condition? Block
  • 24. Iteration (or Looping) Logic (REPEAT…UNTIL Structure) (b) Pseudocode REPEAT Process 1 Process n UNTIL Condition Process 1 Process n True (a) Flowchart False Condition?
  • 27.
  • 28. Flowchart Pseudocode Start/End Begin/End Input/output Read: read x,y Print: Print y Process Computation: X<-y+6 Decision If/if-lse/case/while/ do-while/for Connector Not Applicable Predefined Process Not Applicable FlowchartVs Pseudo code
  • 29. FlowchartVs Pseudo code • Flowchart Advantages • Standard • Visual • Flowchart Disadvantages • Hard to modify • Structured design elements not implemented • Special software required • Pseudocode Advantages • Easily modified • Implements structured concepts • Done easy on Word Processor • Pseudocode Disadvantages • Not Visual • Not accepted standard, varies from company to company
  • 30. Assignments • Write a pseudo code and flowchart to find the given number is prime or not? • Write a pseudo code and flowchart to generate the Fibonacci series upto n numbers. • Write a pseudo code and flowchart to check the given number is palindrome or not?