swift if statement

// if expression {
// 	do something
// }

var a: Int = 3
if a == 3 {
	print("Hello World")
} else if a < 3 {
	print("dlroW olleH")
} else {
	print("42")
}

3.67
6
Tom 75 points

                                    // check the number is positive or negative
let num = 15
var result = &quot;&quot;

if (num &gt; 0) {
     result = &quot;Positive Number&quot;
}
else {
     result = &quot;Negative Number&quot;
}

print(result)

3.67 (6 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
if condition in swift swift if let else if swift with and swift if expression swift if conditional ifdef in swift if else if statment in swift example of if statement swift #if else in swift if &lt;= swift swift else statement what is #if swift swift !if swiftui else of .if statement swift elseif swift if example swift if let statement swift for if if , swift swig if else if statement in swfit examples if and swift if statementr in swift swift ?: if if in swift 4 if else inline swift swift if then statements swift defer statement program doesn't run a IF statment in swift xcode if else if in swift hwo to add if else condition in class in swift control transfer swift how to write a if statement in swfit swift else instruction in swift 5 indstruction in swift 5 how to check book with guard statement do you have to close if statements in swift ios #if statement ios if statement ios #if else if let statement swift if else if swift when statements swift swift do swift if statement examples if condition swift how to code when it is in this value do that swift #if swift do if in swift how to write &quot;and&quot; with an if statement swift how to use and in a if/else statement swift swiftui if statement use where over if in for loop in swift use where or if in swift use where of if in siwft if else in swift 5 how to three values check in if else condition in swift 5 swift if statements swift conditional statement if else condition in swift if statements swift and if statements swift how to write and in a swift if else statement swift if condition and swift as statement if statements in swift c# how to add if in swift return in if statement swift swift and condition if statements swift simplified swift else if and or statement swift else if or statement else if (400...499) means swif tios if then else swift swift if else swift conditional statements swift5 simplified if expression for else swift swift 5 if statement if statment swift swift else if if condition for on recieve swift swiftui button multiple if else swift if statement to class if conditions in swift swift ? if if statement swift why using as? in if statement swift ios why using as? in if statement swift swift if condition if statement swift 5 elif in swift can you use expressiblebybooleanliteral in if statements else if swift if statement on swift difrenten statement in swift if statement swift example how to do if statements in swfit if swift else if case swift else if in swift if else swift else if statement swift if statement in swift swift if statement if else in swift else vs else if swift if loop swift else do swift swift if if statement swfit
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source