adsense


Showing posts with label JAVA PROGRAM TO PRINT FLOYD'S TRIANGLE. Show all posts
Showing posts with label JAVA PROGRAM TO PRINT FLOYD'S TRIANGLE. Show all posts

Monday, 16 November 2015

JAVA PROGRAM TO PRINT FLOYD'S TRIANGLE PAGE 23








COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



JAVA PROGRAM TO PRINT FLOYD'S TRIANGLE







Java program to print Floyd's triangle


This java program prints Floyd's triangle.

Java programming source code

import java.util.Scanner;
 
class FloydTriangle
{
   public static void main(String args[])
   {
      int n, num = 1, c, d;
      Scanner in = new Scanner(System.in);
 
      System.out.println("Enter the number of rows of floyd's triangle you want");
      n = in.nextInt();
 
      System.out.println("Floyd's triangle :-");
 
      for ( c = 1 ; c <= n ; c++ )
      {
         for ( d = 1 ; d <= c ; d++ )
         {
            System.out.print(num+" ");
            num++;
         }
 
         System.out.println();
      }
   }
}