Page 71 - Digicode_AI_class_8
P. 71

Step 3    Modify the ‘on start’ block as shown below.
















            Well done, you have learnt to implement return function.
                                                                                 Information Literacy
                   code Quest                                                    Media Literacy


                   Answer the following questions:
                   1.  What is the main purpose of using functions?


                   2.  What does function returns when an operation is performed inside
                       a function?






            An array is an arrangement of objects. Have you seen an egg box? In an egg box, the eggs are
            arranged in a rectangular fashion. This is an array.

            What are Arrays?

            An array is a collection of similar data type variables. Arrays do not support different data types. For
            example, you can make an array of Integers and another array of Strings, but cannot make an Array
            having Integer and Strings in the same Collection.
            Books in  a  library,  is an  example  of arrays  where  all  the  shelves have  a  common  data  type
            (read – book) in it.
            Advantage of the array is that it improves the readability of code by using a single variable for a
            large set of data. But there are limitations of array also, which are:
            •  You can only store variables with the same data types in an array
            •  The variables in an Array are always ordered sequentially with the index starting  from 0.
            •  Arrays are always static and fixed in length and size.

            Array Declaration
            Declaration of array with variables of integer data type is:

            arr=[10, 20, 30, 40, 50, 60];
             10       20        30       40        50       60


             0        1         2        3         4        5                    Array Indices

            Array Length=6, First index=0, Last index=5

                                                                           Advanced MakeCode Arcade      69
   66   67   68   69   70   71   72   73   74   75   76