SlideShare a Scribd company logo
1 of 30
Understanding Iterations and Implementing
Modular Programming

Objectives
In this lesson, you will learn to:
 Use the dry run table
 Identify repetitive processes
 Represent complex conditions and iterations by using
  flowcharts
 Break down a problem into modules




©NIIT                                PLT/Lesson 3/Slide 1 of 30
Understanding Iterations and Implementing
Modular Programming

Dry Run
 Helps you to do a logic check
 Understand the flow of control in a flowchart
 Evaluate the output of the program with a set of
  sample values
 Provides a step by step evaluation of values in the
  variables of the program




©NIIT                                 PLT/Lesson 3/Slide 2 of 30
Understanding Iterations and Implementing
Modular Programming

Dry Run (Contd.)
Example
All candidates have to take three tests. A candidate is
selected for the interview round based on the scores of
all the three tests. The individual score in each test has
to be greater than 75 and the average score across the
three tests should be a minimum of 80. The call letter for
the interview is to be sent to candidates who have been
selected and a rejection letter is to be sent to the rest.
Represent the logic for the above process by using a
flowchart.



©NIIT                                  PLT/Lesson 3/Slide 3 of 30
Understanding Iterations and Implementing
Modular Programming

Variables

        Variable           Data Type   Variable Name

        Employee Name      character   cName

        Employee Address   character   cAddress

        Telephone Number   character   cTelno

        Counter            numeric     nCounter




©NIIT                                   PLT/Lesson 3/Slide 4 of 30
Understanding Iterations and Implementing
Modular Programming

Flowchart to Select a Candidate
                      Start


                Declare Variables



              Accept Variables and
              Calculate nAverage




                     Is
              nAverage= 80 AND         No   Display “ Rejection
               nTest1  75 AND                letter to be sent”
               nTest2  75 AND
                nTest3  75 ?


                          Yes
               Display “ Interview
              call letter to be sent”


                     Stop

©NIIT                                          PLT/Lesson 3/Slide 5 of 30
Understanding Iterations and Implementing
Modular Programming

Dry Run Table


    S.No.   nTest1   nTest2   nTest 3   nAverage   Output

    1.      95       90       88        91         Interview call letter to be sent.

    2.      80       77       83        80         Interview call letter to be sent.

    3.      90       92       74        85.33      Rejection letter to be sent.

    4.      76       76       76        76         Rejection letter to be sent.




©NIIT                                               PLT/Lesson 3/Slide 6 of 30
Understanding Iterations and Implementing
Modular Programming

Iteration
 An important characteristic of a computer is its ability
  to execute a series of instructions repeatedly
 A loop is a sequence of instructions that will be
  repeated more than once
 A loop performs steps in a specified sequence
 There are two types of loops:
    Fixed loops where the number of repetitions is
     known
     Variable loops where the number of repetitions is
      not known

©NIIT                                  PLT/Lesson 3/Slide 7 of 30
Understanding Iterations and Implementing
Modular Programming

Example
Flowchart to Display the Sum of Ten Numbers
                    Start

                numeric nNum,
               nSum, nCounter


                  nCounter=0
                   nSum=0

                 Accept nNum


              nSum=nSum+nNum


              nCounter=nCounter+1



        Yes          Is          No
                 nCounter10 ?        Display nSum

                                                       Stop
©NIIT                                            PLT/Lesson 3/Slide 8 of 30
Understanding Iterations and Implementing
Modular Programming

Dry Run Table

                S. No.   nNum   nSum   nCounter   Output

                1.       -      0      0

                2.       5      5      1

                3.       12     17     2

                4.       7      24     3

                5.       6      30     4

                6.       2      32     5

                7.       10     42     6

                8.       8      50     7

                9.       3      53     8

                10.      16     69     9

                11.      4      73     10         73




©NIIT                                             PLT/Lesson 3/Slide 9 of 30
Understanding Iterations and Implementing
Modular Programming

Example
You have been assigned the responsibility of generating
an address list of all the people working in your office.
For each person, you will need to accept the name,
address, and the telephone number and print a list
containing the collated details.




©NIIT                                 PLT/Lesson 3/Slide 10 of 30
Understanding Iterations and Implementing
Modular Programming

Flowchart Segment to Display Employee
Details of 25 People
                   nCounter = 1



                      Is            No
                  nCounter=25?

                         Yes               Stop
                  Accept cName



                Accept cAddress



                 Accept cTelno


                  Display cName,
                 cAddress, cTelno


               nCounter=nCounter+
               1
©NIIT                                    PLT/Lesson 3/Slide 11 of 30
Understanding Iterations and Implementing
Modular Programming

Example
Let us look at the same example of preparing the test
performance report in the decision-making section again.
Now, apart from finding out whether a candidate has to
be sent a call letter or a rejection letter, we also have to
calculate the number of candidates who have been sent
interview call letters and the number of candidates who
have been sent rejection letters, using a flowchart.




©NIIT                                  PLT/Lesson 3/Slide 12 of 30
Understanding Iterations and Implementing
Modular Programming

Flowchart to Calculate the Total Number of
Call Letters and Rejection Letters Sent
                        Start


                 Variable Declaration


                    Accept Values



                         Is
                 nAverage =80 AND       No
                  nTest1  75 AND               nTotReject=nTotReject+1
                  nTest2  75 AND
                    nTest3  75 ?


                             Yes

               nTotSelect=nTotSelect+1


          A              B


©NIIT                                         PLT/Lesson 3/Slide 13 of 30
Understanding Iterations and Implementing
Modular Programming

Flowchart to Calculate the Total Number of Call
Letters and Rejection Letters Sent (Contd.)
                          B
           A


                   Display “Any more
                   candidates (Y/N)? ”



                    Accept cChoice



                         Is              No
                    cChoice = “Y”?


                            Yes      Display nTotSelect
                                     Display nTotReject



                                              Stop


©NIIT                                          PLT/Lesson 3/Slide 14 of 30
Understanding Iterations and Implementing
Modular Programming

Dry Run Table


 S. No.   nTest1   nTest2   nTest2   nAverage   Output

 1.       95       90       88       91         nTotSelect is incremented by 1.

 2.       80       77       83       80         nTotSelect is incremented by 1.

 3.       90       92       74       85.33      nTotReject is incremented by 1.

 4.       76       76       76       76         nTotReject is incremented by 1.




©NIIT                                            PLT/Lesson 3/Slide 15 of 30
Understanding Iterations and Implementing
Modular Programming

Modular Approach to Programming
 A program needs to be amended periodically to
  respond to changing conditions or requirements
 This encouraged programmers to adopt a more
  disciplined approach to program writing.
 The techniques that were adopted are known as
  structured programming techniques.
 Structured programming includes features that are
  designed not only to solve the problem at hand but
  also to make the logic clear to someone reading the
  program


©NIIT                               PLT/Lesson 3/Slide 16 of 30
Understanding Iterations and Implementing
Modular Programming

Modular Approach to Programming (Contd.)
 Long, continuous programs can be broken up into a
  series of individual modules that are related to each
  other in a specified manner.

                            Main
                           Program




              Module1      Module2     Module3




©NIIT                                PLT/Lesson 3/Slide 17 of 30
Understanding Iterations and Implementing
Modular Programming

Flowchart to Show Modular Programming

                Start


           numeric nNum1,           Add
         nNum2, nNum3, nSum

                              nSum=nNum1 + nNum2
            Accept nNum1,           + nNum3
            nNum2, nNum3

                                     Return

                Add



           Display nSum



                Stop




©NIIT                             PLT/Lesson 3/Slide 18 of 30
Understanding Iterations and Implementing
Modular Programming

Example
Accept the test scores for ten students and display their
individual averages. The scores of the students cannot
be negative.
The table shows the variables used in the flowchart.
        Variable                 Data Type   Variable Name


        Student Name             character   cStudentName

        Score of Test 1          numeric     nTest1

        Score of Test 2          numeric     nTest2

        Score of Test 3          numeric     nTest3

        Average of Test Scores   numeric     nAverage




©NIIT                                         PLT/Lesson 3/Slide 19 of 30
Understanding Iterations and Implementing
Modular Programming

Flowchart to Calculate Average Marks of Ten
Students
                                  Accept



                           Accept cStudentName
        Accept
                                                                         Average
                               Accept nTest1

        Average                                                  nAverage=(nTest1+nTest2
                               Accept nTest2                                 +nTest3) / 3


 Display cStudentName,         Accept nTest3                              Return
       nAverage


                                  Is
                            nTest1=0 AND             Yes
                            nTest2=0 AND
                             nTest3=0 ?

                                                        Return
                                     No
                         Display “Test score cannot
                            be less than zero”
©NIIT                                            PLT/Lesson 3/Slide 20 of 30
Understanding Iterations and Implementing
Modular Programming

Example
The total expenditure on salaries for the month needs to
be calculated. As per company policy an employee
receives a minimum of $500. Depict the logic for
automating the task by using flowcharts.
Program Variables to be used are:
   Variable          Data Type        Variable Name

   Employee Code     character        cEmpCode

   Employee salary   numeric          nSalary

   Total salary      numeric          nTotSalary

   Choice            character        cChoice



©NIIT                                PLT/Lesson 3/Slide 21 of 30
Understanding Iterations and Implementing
Modular Programming

Flowchart to Calculate Total Monthly Expenditure
on Salaries
                             Accept



      Is          No                                                   Summation
cChoice = “Y” ?           Accept nSalary


        Yes
                                                              nTotSalary=nTotSalary+nSalary
                               Is              Yes
   Accept               nSalary =500 ?

                                                     Return              Return
                                No
 Summation             Display”Salary cannot
                       be less than $500”




©NIIT                                                    PLT/Lesson 3/Slide 22 of 30
Understanding Iterations and Implementing
Modular Programming

Example
Dry Run
          S. No.   nSalary   nTotSalary   Output

          1.       -         0

          2.       4500      4500

          3.       5500      10000

          4.       3400      13400

          5.       5600      19000

          6.       3000      22000

          7.       5000      27000

          8.       450       27000        Salary cannot be less than $500

          9.       9000      36000

          10.      8900      44900

          11.      4500      49400        49400
©NIIT                                              PLT/Lesson 3/Slide 23 of 30
Understanding Iterations and Implementing
Modular Programming

Problem Statement 3.P.1
Draw a flowchart to print the product of the first 10 even
numbers.




©NIIT                                  PLT/Lesson 3/Slide 24 of 30
Understanding Iterations and Implementing
Modular Programming

Problem Statement 3.P.2
Draw a flowchart to accept 50 numbers and also display
the total number of odd and even numbers.




©NIIT                               PLT/Lesson 3/Slide 25 of 30
Understanding Iterations and Implementing
Modular Programming

Problem Statement 3.P.3
Draw a flowchart to display the highest of any 10
numbers entered.




©NIIT                                PLT/Lesson 3/Slide 26 of 30
Understanding Iterations and Implementing
Modular Programming

Problem Statement 3.P.4
        Draw a flowchart that accepts input from a user and
        displays the result, depending on whether the user
        wishes to multiply or divide the numbers provided
        as input. The Multiply module of the program can
        multiply maximum of three numbers. The Divide
        module of the program should check that the
        denominator should not be zero.




©NIIT                                  PLT/Lesson 3/Slide 27 of 30
Understanding Iterations and Implementing
Modular Programming

Problem Statement 3.P.5
How many names will the following flowchart print?


                          nCtr = 0



                        Accept cName



                        Display cName




                   No        Is
                          nCtr =10 ?


                              Yes

                           Stop


©NIIT                                   PLT/Lesson 3/Slide 28 of 30
Understanding Iterations and Implementing
Modular Programming

Summary
In this lesson, you learned that:
 The concept of dry run will help you perform a logic
  check and understand the flow of control in a
  flowchart.
 A loop is a sequence of instructions that will be
  repeated more than once
 A loop performs steps in a specified sequence
 There are two types of loops:
        ® Fixed
              loops where the number of repetitions is
         known

©NIIT                                 PLT/Lesson 3/Slide 29 of 30
Understanding Iterations and Implementing
Modular Programming

Summary (Contd.)
        ® Variable   loops where the number of repetitions is not
         known
 Statements within a loop will be executed repeatedly
  until the condition becomes false
 The structured programming technique is a disciplined
 approach to program writing.
 A large program can be divided into several modules,
  where each module performs a specific task. A module
  is also called a procedure.
 A procedure or a module is invoked from the main
  program and the control is returned from the procedure to
  the main program by using the return statement

©NIIT                                      PLT/Lesson 3/Slide 30 of 30

More Related Content

Similar to Sem1 plt xp_03

Unit2 algorithmic problem_solving
Unit2 algorithmic problem_solvingUnit2 algorithmic problem_solving
Unit2 algorithmic problem_solvingCapuchino HuiNing
 
Aplicaciones de la derivadas en contabilidad
Aplicaciones de la derivadas en contabilidadAplicaciones de la derivadas en contabilidad
Aplicaciones de la derivadas en contabilidadviniciomuozcONTRERAS
 
Introduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdfIntroduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdfTulasiramKandula1
 
Problem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study materialProblem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study materialTo Sum It Up
 
Design and Implementation of Test Vector Generation using Random Forest Techn...
Design and Implementation of Test Vector Generation using Random Forest Techn...Design and Implementation of Test Vector Generation using Random Forest Techn...
Design and Implementation of Test Vector Generation using Random Forest Techn...IRJET Journal
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 solIIUM
 
Aae oop xp_07
Aae oop xp_07Aae oop xp_07
Aae oop xp_07Niit Care
 
02 intel v_tune_session_02
02 intel v_tune_session_0202 intel v_tune_session_02
02 intel v_tune_session_02Vivek chan
 
Rightand wrong[1]
Rightand wrong[1]Rightand wrong[1]
Rightand wrong[1]slange
 
CS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsCS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsKrishnan MuthuManickam
 
Testing of Matrices Multiplication Methods on Different Processors
Testing of Matrices Multiplication Methods on Different ProcessorsTesting of Matrices Multiplication Methods on Different Processors
Testing of Matrices Multiplication Methods on Different ProcessorsEditor IJMTER
 
Cpm module iii reference
Cpm module iii referenceCpm module iii reference
Cpm module iii referenceahsanrabbani
 
09_Control_Structures_and_Flowcharts.pdf
09_Control_Structures_and_Flowcharts.pdf09_Control_Structures_and_Flowcharts.pdf
09_Control_Structures_and_Flowcharts.pdfziwei13579
 
#include iostream#includectimeusing namespace std;void.docx
#include iostream#includectimeusing namespace std;void.docx#include iostream#includectimeusing namespace std;void.docx
#include iostream#includectimeusing namespace std;void.docxmayank272369
 
Accelerating Dynamic Time Warping Subsequence Search with GPU
Accelerating Dynamic Time Warping Subsequence Search with GPUAccelerating Dynamic Time Warping Subsequence Search with GPU
Accelerating Dynamic Time Warping Subsequence Search with GPUDavide Nardone
 
virtualization
virtualizationvirtualization
virtualizationAvi Nash
 

Similar to Sem1 plt xp_03 (20)

Unit2 algorithmic problem_solving
Unit2 algorithmic problem_solvingUnit2 algorithmic problem_solving
Unit2 algorithmic problem_solving
 
Aplicaciones de la derivadas en contabilidad
Aplicaciones de la derivadas en contabilidadAplicaciones de la derivadas en contabilidad
Aplicaciones de la derivadas en contabilidad
 
Introduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdfIntroduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdf
 
Problem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study materialProblem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study material
 
Design and Implementation of Test Vector Generation using Random Forest Techn...
Design and Implementation of Test Vector Generation using Random Forest Techn...Design and Implementation of Test Vector Generation using Random Forest Techn...
Design and Implementation of Test Vector Generation using Random Forest Techn...
 
LMmanual.pdf
LMmanual.pdfLMmanual.pdf
LMmanual.pdf
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 
Aae oop xp_07
Aae oop xp_07Aae oop xp_07
Aae oop xp_07
 
02 intel v_tune_session_02
02 intel v_tune_session_0202 intel v_tune_session_02
02 intel v_tune_session_02
 
Book
BookBook
Book
 
markomanolis_phd_defense
markomanolis_phd_defensemarkomanolis_phd_defense
markomanolis_phd_defense
 
Rightand wrong[1]
Rightand wrong[1]Rightand wrong[1]
Rightand wrong[1]
 
CS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of AlgorithmsCS8451 - Design and Analysis of Algorithms
CS8451 - Design and Analysis of Algorithms
 
Testing of Matrices Multiplication Methods on Different Processors
Testing of Matrices Multiplication Methods on Different ProcessorsTesting of Matrices Multiplication Methods on Different Processors
Testing of Matrices Multiplication Methods on Different Processors
 
Cpm module iii reference
Cpm module iii referenceCpm module iii reference
Cpm module iii reference
 
09_Control_Structures_and_Flowcharts.pdf
09_Control_Structures_and_Flowcharts.pdf09_Control_Structures_and_Flowcharts.pdf
09_Control_Structures_and_Flowcharts.pdf
 
#include iostream#includectimeusing namespace std;void.docx
#include iostream#includectimeusing namespace std;void.docx#include iostream#includectimeusing namespace std;void.docx
#include iostream#includectimeusing namespace std;void.docx
 
Accelerating Dynamic Time Warping Subsequence Search with GPU
Accelerating Dynamic Time Warping Subsequence Search with GPUAccelerating Dynamic Time Warping Subsequence Search with GPU
Accelerating Dynamic Time Warping Subsequence Search with GPU
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
virtualization
virtualizationvirtualization
virtualization
 

More from Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 

Recently uploaded

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 

Recently uploaded (20)

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 

Sem1 plt xp_03

  • 1. Understanding Iterations and Implementing Modular Programming Objectives In this lesson, you will learn to: Use the dry run table Identify repetitive processes Represent complex conditions and iterations by using flowcharts Break down a problem into modules ©NIIT PLT/Lesson 3/Slide 1 of 30
  • 2. Understanding Iterations and Implementing Modular Programming Dry Run Helps you to do a logic check Understand the flow of control in a flowchart Evaluate the output of the program with a set of sample values Provides a step by step evaluation of values in the variables of the program ©NIIT PLT/Lesson 3/Slide 2 of 30
  • 3. Understanding Iterations and Implementing Modular Programming Dry Run (Contd.) Example All candidates have to take three tests. A candidate is selected for the interview round based on the scores of all the three tests. The individual score in each test has to be greater than 75 and the average score across the three tests should be a minimum of 80. The call letter for the interview is to be sent to candidates who have been selected and a rejection letter is to be sent to the rest. Represent the logic for the above process by using a flowchart. ©NIIT PLT/Lesson 3/Slide 3 of 30
  • 4. Understanding Iterations and Implementing Modular Programming Variables Variable Data Type Variable Name Employee Name character cName Employee Address character cAddress Telephone Number character cTelno Counter numeric nCounter ©NIIT PLT/Lesson 3/Slide 4 of 30
  • 5. Understanding Iterations and Implementing Modular Programming Flowchart to Select a Candidate Start Declare Variables Accept Variables and Calculate nAverage Is nAverage= 80 AND No Display “ Rejection nTest1 75 AND letter to be sent” nTest2 75 AND nTest3 75 ? Yes Display “ Interview call letter to be sent” Stop ©NIIT PLT/Lesson 3/Slide 5 of 30
  • 6. Understanding Iterations and Implementing Modular Programming Dry Run Table S.No. nTest1 nTest2 nTest 3 nAverage Output 1. 95 90 88 91 Interview call letter to be sent. 2. 80 77 83 80 Interview call letter to be sent. 3. 90 92 74 85.33 Rejection letter to be sent. 4. 76 76 76 76 Rejection letter to be sent. ©NIIT PLT/Lesson 3/Slide 6 of 30
  • 7. Understanding Iterations and Implementing Modular Programming Iteration An important characteristic of a computer is its ability to execute a series of instructions repeatedly A loop is a sequence of instructions that will be repeated more than once A loop performs steps in a specified sequence There are two types of loops: Fixed loops where the number of repetitions is known Variable loops where the number of repetitions is not known ©NIIT PLT/Lesson 3/Slide 7 of 30
  • 8. Understanding Iterations and Implementing Modular Programming Example Flowchart to Display the Sum of Ten Numbers Start numeric nNum, nSum, nCounter nCounter=0 nSum=0 Accept nNum nSum=nSum+nNum nCounter=nCounter+1 Yes Is No nCounter10 ? Display nSum Stop ©NIIT PLT/Lesson 3/Slide 8 of 30
  • 9. Understanding Iterations and Implementing Modular Programming Dry Run Table S. No. nNum nSum nCounter Output 1. - 0 0 2. 5 5 1 3. 12 17 2 4. 7 24 3 5. 6 30 4 6. 2 32 5 7. 10 42 6 8. 8 50 7 9. 3 53 8 10. 16 69 9 11. 4 73 10 73 ©NIIT PLT/Lesson 3/Slide 9 of 30
  • 10. Understanding Iterations and Implementing Modular Programming Example You have been assigned the responsibility of generating an address list of all the people working in your office. For each person, you will need to accept the name, address, and the telephone number and print a list containing the collated details. ©NIIT PLT/Lesson 3/Slide 10 of 30
  • 11. Understanding Iterations and Implementing Modular Programming Flowchart Segment to Display Employee Details of 25 People nCounter = 1 Is No nCounter=25? Yes Stop Accept cName Accept cAddress Accept cTelno Display cName, cAddress, cTelno nCounter=nCounter+ 1 ©NIIT PLT/Lesson 3/Slide 11 of 30
  • 12. Understanding Iterations and Implementing Modular Programming Example Let us look at the same example of preparing the test performance report in the decision-making section again. Now, apart from finding out whether a candidate has to be sent a call letter or a rejection letter, we also have to calculate the number of candidates who have been sent interview call letters and the number of candidates who have been sent rejection letters, using a flowchart. ©NIIT PLT/Lesson 3/Slide 12 of 30
  • 13. Understanding Iterations and Implementing Modular Programming Flowchart to Calculate the Total Number of Call Letters and Rejection Letters Sent Start Variable Declaration Accept Values Is nAverage =80 AND No nTest1 75 AND nTotReject=nTotReject+1 nTest2 75 AND nTest3 75 ? Yes nTotSelect=nTotSelect+1 A B ©NIIT PLT/Lesson 3/Slide 13 of 30
  • 14. Understanding Iterations and Implementing Modular Programming Flowchart to Calculate the Total Number of Call Letters and Rejection Letters Sent (Contd.) B A Display “Any more candidates (Y/N)? ” Accept cChoice Is No cChoice = “Y”? Yes Display nTotSelect Display nTotReject Stop ©NIIT PLT/Lesson 3/Slide 14 of 30
  • 15. Understanding Iterations and Implementing Modular Programming Dry Run Table S. No. nTest1 nTest2 nTest2 nAverage Output 1. 95 90 88 91 nTotSelect is incremented by 1. 2. 80 77 83 80 nTotSelect is incremented by 1. 3. 90 92 74 85.33 nTotReject is incremented by 1. 4. 76 76 76 76 nTotReject is incremented by 1. ©NIIT PLT/Lesson 3/Slide 15 of 30
  • 16. Understanding Iterations and Implementing Modular Programming Modular Approach to Programming A program needs to be amended periodically to respond to changing conditions or requirements This encouraged programmers to adopt a more disciplined approach to program writing. The techniques that were adopted are known as structured programming techniques. Structured programming includes features that are designed not only to solve the problem at hand but also to make the logic clear to someone reading the program ©NIIT PLT/Lesson 3/Slide 16 of 30
  • 17. Understanding Iterations and Implementing Modular Programming Modular Approach to Programming (Contd.) Long, continuous programs can be broken up into a series of individual modules that are related to each other in a specified manner. Main Program Module1 Module2 Module3 ©NIIT PLT/Lesson 3/Slide 17 of 30
  • 18. Understanding Iterations and Implementing Modular Programming Flowchart to Show Modular Programming Start numeric nNum1, Add nNum2, nNum3, nSum nSum=nNum1 + nNum2 Accept nNum1, + nNum3 nNum2, nNum3 Return Add Display nSum Stop ©NIIT PLT/Lesson 3/Slide 18 of 30
  • 19. Understanding Iterations and Implementing Modular Programming Example Accept the test scores for ten students and display their individual averages. The scores of the students cannot be negative. The table shows the variables used in the flowchart. Variable Data Type Variable Name Student Name character cStudentName Score of Test 1 numeric nTest1 Score of Test 2 numeric nTest2 Score of Test 3 numeric nTest3 Average of Test Scores numeric nAverage ©NIIT PLT/Lesson 3/Slide 19 of 30
  • 20. Understanding Iterations and Implementing Modular Programming Flowchart to Calculate Average Marks of Ten Students Accept Accept cStudentName Accept Average Accept nTest1 Average nAverage=(nTest1+nTest2 Accept nTest2 +nTest3) / 3 Display cStudentName, Accept nTest3 Return nAverage Is nTest1=0 AND Yes nTest2=0 AND nTest3=0 ? Return No Display “Test score cannot be less than zero” ©NIIT PLT/Lesson 3/Slide 20 of 30
  • 21. Understanding Iterations and Implementing Modular Programming Example The total expenditure on salaries for the month needs to be calculated. As per company policy an employee receives a minimum of $500. Depict the logic for automating the task by using flowcharts. Program Variables to be used are: Variable Data Type Variable Name Employee Code character cEmpCode Employee salary numeric nSalary Total salary numeric nTotSalary Choice character cChoice ©NIIT PLT/Lesson 3/Slide 21 of 30
  • 22. Understanding Iterations and Implementing Modular Programming Flowchart to Calculate Total Monthly Expenditure on Salaries Accept Is No Summation cChoice = “Y” ? Accept nSalary Yes nTotSalary=nTotSalary+nSalary Is Yes Accept nSalary =500 ? Return Return No Summation Display”Salary cannot be less than $500” ©NIIT PLT/Lesson 3/Slide 22 of 30
  • 23. Understanding Iterations and Implementing Modular Programming Example Dry Run S. No. nSalary nTotSalary Output 1. - 0 2. 4500 4500 3. 5500 10000 4. 3400 13400 5. 5600 19000 6. 3000 22000 7. 5000 27000 8. 450 27000 Salary cannot be less than $500 9. 9000 36000 10. 8900 44900 11. 4500 49400 49400 ©NIIT PLT/Lesson 3/Slide 23 of 30
  • 24. Understanding Iterations and Implementing Modular Programming Problem Statement 3.P.1 Draw a flowchart to print the product of the first 10 even numbers. ©NIIT PLT/Lesson 3/Slide 24 of 30
  • 25. Understanding Iterations and Implementing Modular Programming Problem Statement 3.P.2 Draw a flowchart to accept 50 numbers and also display the total number of odd and even numbers. ©NIIT PLT/Lesson 3/Slide 25 of 30
  • 26. Understanding Iterations and Implementing Modular Programming Problem Statement 3.P.3 Draw a flowchart to display the highest of any 10 numbers entered. ©NIIT PLT/Lesson 3/Slide 26 of 30
  • 27. Understanding Iterations and Implementing Modular Programming Problem Statement 3.P.4 Draw a flowchart that accepts input from a user and displays the result, depending on whether the user wishes to multiply or divide the numbers provided as input. The Multiply module of the program can multiply maximum of three numbers. The Divide module of the program should check that the denominator should not be zero. ©NIIT PLT/Lesson 3/Slide 27 of 30
  • 28. Understanding Iterations and Implementing Modular Programming Problem Statement 3.P.5 How many names will the following flowchart print? nCtr = 0 Accept cName Display cName No Is nCtr =10 ? Yes Stop ©NIIT PLT/Lesson 3/Slide 28 of 30
  • 29. Understanding Iterations and Implementing Modular Programming Summary In this lesson, you learned that: The concept of dry run will help you perform a logic check and understand the flow of control in a flowchart. A loop is a sequence of instructions that will be repeated more than once A loop performs steps in a specified sequence There are two types of loops: ® Fixed loops where the number of repetitions is known ©NIIT PLT/Lesson 3/Slide 29 of 30
  • 30. Understanding Iterations and Implementing Modular Programming Summary (Contd.) ® Variable loops where the number of repetitions is not known Statements within a loop will be executed repeatedly until the condition becomes false The structured programming technique is a disciplined approach to program writing. A large program can be divided into several modules, where each module performs a specific task. A module is also called a procedure. A procedure or a module is invoked from the main program and the control is returned from the procedure to the main program by using the return statement ©NIIT PLT/Lesson 3/Slide 30 of 30