0

On line no no of stars
1 1
2 3
3 5
4 3
5 1

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

Edited by anjal_pawar: NOT DISPLAYED PROPERLY

5
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by javaAddict
0

i need more explanation on it.

no you don't. you gave all the explanation to find the answer in your first post:
it's a PATTERN that you want to PRINT
there are only very basic techniques used there, no doubt your teacher showed you those.

0

2 for loops.
Outer: 1 to 5 for the lines.
Inner: Depending on the index of the first loop you will decide how many stars will be printed. The number of stars will be the number of times the inner loop will run.

Also:
System.out.println() : Changes lines
System.out.print("*") : Prints '*' at the same line

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.