In this post, We will share a Nested if…else Statement in Swift programming with an example and real-time output. This is a very basic program in Swift programming language. If you are Swift beginners or want to start learning Swift programming language, then this program will help you to understand the basic Swift programming.
Copy the below program and create a file named “NestedIfElse.swift” and execute it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #define variables let n1 = -1.0, n2 = 5, n3 = -5.3 if n1 >= n2 { if n1 >= n3 { print("The largest number is ", n1) } else { print("The largest number is ", n3) } } else { if n2 >= n3 { print("The largest number is ", n2) } else { print("The largest number is ", n3) } } |
The The largest number is 5
Liked this program? Do Like & share with your friends.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.