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 5

import Foundation
import Glibc
/*
var arrOfNames: [String] = ["Ahmed", "Belal", "Abdelhamed", "Asmaa", "Salma", "Jacky"]
for name in arrOfNames {
    print("Hello \(name)")
}
print(arrOfNames.count)
print(arrOfNames[0])
//arrOfNames += ["Ali"]
//arrOfNames.insert("ali", at: 1)
//arrOfNames.remove(at: 1)
for name in arrOfNames {
    print("Hello \(name)")
}
*/

/*
//Task 1
var listOfNumbers = [1, 2, 63, 10, 50]
var max = listOfNumbers[0]
for number in listOfNumbers {
    if max < number {
        max = number
    }
}
print(max)

*/
var listOfNumbers = [1, 2, 3, 10, 100]
for number in listOfNumbers {
    if number % 2 != 0 {
       print(number)
    }
}








Advertisements
Loading...

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