“Pernyataan IF bersarang” Kode Jawaban

Bersarang jika ... pernyataan lain

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");
}
SAMER SAEID

Pernyataan IF bersarang

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
}
Gorgeous Goldfinch

Bersarang jika ... pernyataan lain

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);
				}
			}
		}
	}
}
SAMER SAEID

Contoh pernyataan bersarang jika

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");
         }
      }
   }
}
Important Ibis

Jawaban yang mirip dengan “Pernyataan IF bersarang”

Pertanyaan yang mirip dengan “Pernyataan IF bersarang”

Lebih banyak jawaban terkait untuk “Pernyataan IF bersarang” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya