Tuesday, 27 June 2017

👉Program-To Print Floyd Triangle  



  1.  import java.util.Scanner;
  2. public class FloydTriangle{
  3. public static void main(String[] args){
  4. Scanner in = new Scanner(System.in);
  5. System.out.println("Enter the number of rows which you want in your Floyd Triangle: ");
  6. int r = in.nextInt();
  7. int n=0;
  8. for(int i=0; i<r; i++){
  9. for(int j=0; j<=i; j++){
  10. System.out.print(++n+" ");
  11. }
  12. System.out.println();
  13. }
  14. }
  15. }

No comments:

Post a Comment