Swift Program to Access Array Elements Using Foreach() Function

You are currently viewing Swift Program to Access Array Elements Using Foreach() Function

Swift program to access array elements using forEach() function

// Swift program to access array elements using
// forEach() function

import Swift

var arr:[Int] = [12,10,25,20,50]

print("Array elements: ")
arr.forEach {
    print($0)
}

Output

Array elements: 
12
10
25
20
50

...Program finished with exit code 0
Press ENTER to exit console.

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply