100+ Java Programs with Output: Useful collection of Java Programs by Aniket Pataskar

100+ Java Programs with Output: Useful collection of Java Programs by Aniket Pataskar

Author:Aniket Pataskar
Language: eng
Format: epub, azw3
Published: 2016-01-25T23:00:00+00:00


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[]) {

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();

}

}

int n, num = 1, c, d;



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.