Thursday, 3 December 2020

Write a program in Java to Print Floyd's Triangle

 /*

 Floyd's Triangle:

 1

 2 3

 4 5 6

 7 8 9 10

 11 12 13 14 15

 */ 

public class Main

{

   public static void main (String[] args)

   {

   int i,j,p;

   for(i=1,p=1;i<=5;i++)

   {

       for(j=1;j<=i;j++)

       {

       System.out.print(p+" ");

       p++;

       }

       System.out.println();

   }

   }

    

}

No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...