Answers for "Floyd's triangle number pattern using while loop in java"

1

Floyd's triangle number pattern using while loop in java

// Floyd's triangle number pattern using while loop in java
import java.util.Scanner;
public class FloydTriangleWhileLoop
{
   public static void main(String[] args) 
   {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the number of rows of floyd's triangle you want to print: ");
      int rows = sc.nextInt();
      int number = 1;
      System.out.println("Floyd triangle in java using while loop");
      int a = 1;
      int b = 1;
      while(a <= rows)
      {
         b = 1;
         while(b <= a)
         {
            System.out.println(number + " ");
            number++;
            b++;
         }
         System.out.println();
         a++;
      }
      sc.close();
   }
}
Posted by: Guest on February-18-2021

Code answers related to "Floyd's triangle number pattern using while loop in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language