Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Session 4 Tasks

import Foundation
import Glibc
/*
//Task 1 
let N: Int = 10
var power: Int = 1
while power <= N {
    print(power * power)
    power += 1
}


//Task 2
let N = 9
var left = 1
var right = N
while left < right {
    print(left)
    print(right)
    right = N - left
    left += 1
} 
if left == right{
print(right)
}


//Task 3
let N: Int = 4
var times = 1
while times <= N {
    for _ in 1...N {
      print("*",terminator: " ")
      
    }
    print("")
    times += 1
} 


//Task 4 
var n = 2
var m = 3
for _ in 1...n {
    for _ in 1...m {
         print("*",terminator: " ")
    }
    print("")
}
*/







Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.