Swift Program To Create A Function With No Argument But A Return Value

Swift Program To Create A Function With No Argument But A Return Value

Swift Program To Create A Function With No Argument But A Return Value

// Swift program to create a function
// with no argument but a return value

import Swift

func AddNum()->Int {
    let num1:Int = 10
    let num2:Int = 20

    return num1+num2
}

var res:Int = 0

res = AddNum()
print("Addition is: ",res)

Output

Addition is:  30

...Program finished with exit code 0
Press ENTER to exit console.
Share on:

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

Leave a Comment