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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started