Full width home advertisement

Java

Tech News

Ad

  1. package clgPracticals;
  2.  
  3. public class Pr6 {
  4. public static void main(String[] args) {
  5. //this will display Triangle of Numbers
  6. System.out.println("\nDisplaying Number Triangle");
  7. for(int i=1;i<=5;i++) {
  8. for(int j=1;j<=i;j++) {
  9. System.out.print(i);
  10. }
  11. System.out.println();
  12. }
  13.  
  14. System.out.println();
  15. for(int i=1;i<=5;i++) {
  16. for(int j=1;j<=i;j++) {
  17. System.out.print(j);
  18. }
  19. System.out.println();
  20. }
  21.  
  22. //this will Display Triangle of stars
  23. System.out.println("\nDisplaying star Triangle");
  24. for(int i=0;i<5;i++) {
  25. for(int j=0;j<i;j++)
  26. System.out.print("*");
  27. System.out.println();
  28. }
  29. }
  30. }
  31.  

No comments:

Post a Comment

Bottom Ad [Post Page]