Question: 1.This code first step up a function for calcluting and printing squares of number from 0 to 5 after a definition of the function is

1.This code first step up a function for calcluting and printing squares of number from 0 to 5 after a definition of the function is then called to execute it.

The following applies to function

First the variable for storing squares of number is declared.

Following this is for loop. The first step withing the for loop is to determine the square of current value for the vaiable . the second step is to print value of i variable the square of value for i.

Now the loop is finised the function is also completed all that remains is to call the function. (rearrange it)

....... Square()

...... for I in 0..<6 {

..... } // end func square()

..... sqr = 0

..... var sqr

..... func square (){

..... sqr =i*i

..... print("the square of \(i) is:\(sqr)")

.... // the following statement is call to the square () function

..... }// end for

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!