0

how i can solve this problem.....
generate the following staircase pattern(using loop operation)

1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
6 12 18 24 30 36
7 14 21 28 35 42 49

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

Hi ronyyy,

DaniWeb has a golden rule that we only give homework help to those who have shown some effort first. Have you attempted the problem yet? If so, please post your code snippet and describe what problems you are having, otherwise what ideas have you come up with for your algorithm?

1

Here's something to think about to jumpstart your forming of an algorithm -- consider using nested loops. Have the outer loop keep track of the row and each time it completes have it jump to the next row, and have the inner loop print the contents of the row. Think about it and see where you get.

-3
public class Nomames {
	public static void main(String[] args) {
		for(int i = 1 ; i < 100 ; i++){
			for (int j = 1 ; j < i+1 ; j++){
				System.out.print( i*j + " " );
			}
			System.out.println();
		}
	}
}
Votes + Comments
I already told the OP that we wouldn't just give them the answer, what have you taught them with your post??
We are not here to give people they homeworks, we are here to guide them. By giving out solution so easily they will learn nothing
0

thanks endsamsara.....
...........ur program has worked for me with a little modification.......again...many many thanks....:-)

0

hii....darkagn..
..sory..i didn't know about the golden rule..........and yes...i tried to solve this program......but ..i don't know what is the problem....

public class Task2 {


public static void main(String[] args)
{

for (int row = 1; row <= 9; row++)
{
for (int column = row; column <2* row; column++)
System.out.print(column + " ");


System.out.println();
}

System.out.println();
System.out.println();

}
}

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.