i need desperate help with this one nested loop program:

123454321
1234-4321
123---321
12-----21

(the '-'s are actually supposed to be spaces)

Recommended Answers

All 3 Replies

What do you need help with? What have you done? This is clearly homework, so we need some proof of effort before helping (as per Daniweb rules).

As a current student myself, I guess he needs help writing a loop to print what he posted.
I'll get you started by explaining the FOR loop.

That loop cosists of 4 parts:

  1. The initial position of your loop
  2. The condition which signals the end of your loop
  3. What is to be done after each iteration
  4. the iteration/process itself

In code, that would be sketched like so:

for (1; 2; 3;) {
        4;
}

In java:

for (int i = 0; i <= 10; i++){
    System.out.println(i);
}

This example would have this output:

0
1
2
3
4
5
6
7
8
9
10

Hello akash_6:
What are the specs (specifications) of the project and what specific question do you have about it? What have you done so far?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.