Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 112 - 2609_Logicode
P. 112

    RETURNING VALUE FROM A FUNCTION

                      The main purpose of using functions is to get rid of the repetitive block of code. So, when an
                      operation is performed inside a function it gives back a value, which can be used later in the
                      program to get the results, which makes a function more useful.

                      Let us create a project that demonstrates the use of function block for calculating volume of a
                      cuboid using parameters and arguments and return block. Follow the given steps to make the
                      project in MakeCode Arcade:
                       Step 1   Create a new project.

                       Step 2    Select Make a function in the Functions category from the Blocks Palette and name it
                               VolumeofCuboid.

                       Step 3    Name the function in the Edit Function dialog box and add three Number as 3 different
                               parameters.

                       Step 4   Click Done.

                      110   Premium Edition-VIII

| 107 108 109 110 111 112 113 114 115 116 117 |