Sunday, 26 May 2013

How to print stars in right-triangle using JAVA??

Code to print stars in Right-Triangle using JAVA:
package basics;
public class Stars {
public static void main(String[] args) {
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print("*");
}
System.out.println("");
}
}
}


Output for the above Code: 

*
**
***
****
*****

Technology
Tags: ,,

No comments:

Post a Comment

Post a Comment