Page 75 - 2502_Pakistan-kifayat_C-8
P. 75

#Nesting




                  Chapter 5




                   #Chapter Profile
                      What is Nesting?                                      Constants and Variables
                      Conditional Statements                                Repeat and Forever Loops
                      Nesting in Loops and Conditions                       Using If with Multiple Conditions
                      Using Sequence, Loops, and Conditions





                               Take Off                                                           Century   #Critical Thinking
                                                                                                     21 st
                                                                                                    Skills
                      Identify the following terms:

                      1.  A step-by-step set of instructions used to solve a problem.

                      2.  The algorithm in graphical form using symbols.

                      3.   It describes an algorithm in simple, human-readable language without
                         syntax.






                 In the previous chapter, you learnt how to define problems, create algorithms, and represent them
                 using pseudocode. In this chapter, you will build on that knowledge by learning how to use nesting,
                 placing one block of code inside another, to solve more complex problems effectively.


                      WHAT IS NESTING?


                 Nesting means putting one block of code inside another. For example, we can place an if condition
                 inside a loop, or a loop inside another loop. This helps organise the logic clearly and reduces repetition
                 in the code. It also makes the program easier to understand and manage.

                 Why is Nesting Important?

                 Nesting allows us to solve more complex problems. It helps the computer:

                    Make decisions based on different situations.
                    Repeat tasks while checking other conditions.
   70   71   72   73   74   75   76   77   78   79   80