Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

Nested if...else Statement

var number = 5
// outer if statement
if (number >= 0) {

  // inner if statement
  if (number == 0) {
      print("Number is 0")
  }

  // inner else statement
  else {
      print("Number is positive");
  }
}

// outer else statement
else {
    print("Number is negative");
}
Comment

nested if statement

if (condition) {

  if (anotherCondition) {
    // executes if both condition and anotherCondition are true
  } else {
    // executes if condition is true and anotherCondition is false
  }

} else {
  // executes if condition is false
}
Comment

Nested if...else Statement

using System;
 
namespace Conditional
{
	class Nested
	{
		public static void Main(string[] args)
		{
			int first = 7, second = -23, third = 13;
			if (first > second)
			{
				if (firstNumber > third)
				{
					Console.WriteLine("{0} is the largest", first);
				}
				else
				{
					Console.WriteLine("{0} is the largest", third);
				}
			}
			else
			{
				if (second > third)
				{
					Console.WriteLine("{0} is the largest", second);
				}
				else
				{
					Console.WriteLine("{0} is the largest", third);
				}
			}
		}
	}
}
Comment

Example of Nested IF Statement

public class Test {

   public static void main(String args[]) {
      int x = 30;
      int y = 10;

      if( x == 30 ) {
         if( y == 10 ) {
            System.out.print("X = 30 and Y = 10");
         }
      }
   }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: uilabel set font 
Swift :: response.result.value alamofire 5 
Swift :: how to set return type swift 
Swift :: swift stack view scrollable 
Swift :: swift extension Array where element 
Swift :: Function Inside Swift Struct 
Swift :: make text autoresize swiftui 
Swift :: swift guard statement 
Swift :: swift enum xib 
Swift :: swift view 
Swift :: swift 
Swift :: Swift Right Shift Operator 
Swift :: Swift Double 
Swift :: swift disable modal dismiss swift 
Swift :: how to create button action programmatically in ios 
Swift :: Swift is case-sensitive. So A and a are different variables 
Swift :: create a dictionary in swift 
Swift :: swift core data order by 
Swift :: Swift Escape Sequences 
Swift :: change button image tint color swift 
Swift :: Swift Benefits of Using Functions 
Swift :: selector cannot call in notification observer swift 
Swift :: Swift repeat...while Loop 
Swift :: Swift Difference between Two Sets 
Swift :: swift Equatable 
Ruby :: ruby json parse symbolize_keys 
Ruby :: ruby current date and time 
Ruby :: ruby non greedy regex 
Ruby :: head in rails 
Ruby :: rails reset database 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =