Monday, March 3, 2008
Print Triangle using "*"
import java.io.*;
class startriangle{
public static void main(String[] args) {
try{
BufferedReader object = new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the number");
int a= Integer.parseInt(object.readLine());
for (int i=1; i<'a;i++ ){
for (int j=1; j<=i;j++ ){
System.out.print("*");
}
System.out.println("");
}
}
catch(Exception e){}
}
}
Subscribe to:
Post Comments (Atom)
1 comments:
Hello, friends,
The example is good, but...
Let us write
i<=a
Instead of
i<'a.
Now all is OK.
Enter the number
7
*
**
***
****
*****
******
*******
Vladimir
Post a Comment