Hello. I need to reproduce this pattern using one main for loop and one nested for loop. I cannot seem to figure out the right way to do this. I came close, but not close enough.
0
10
210
3210
43210
543210
6543210
76543210
876543210
9876543210

for (int x = 0; x < 10; x++)
 		{
 			for (int y = 0; y < x; y++)
 			{
 				System.out.print(y);
 			}
 			System.out.println();
 		}
Member Avatar for iamthwee

Draw a flow chart first!

I would use an array of ints. Then loop through the length of the array. Then the nested loop output the numbers from the end of the array back to the beginning using the first loop as the counter to denote how many elements need printing.

Member Avatar for iamthwee

Using an array isn't needed here. It unnecessarily adds to the space complexity problem.

Thats true. I didn't look at the order of the numbers:$

0
10
210
3210
43210
543210
6543210
76543210
876543210
9876543210

code for this is
///

public class looping 
       {
          public static void main(String args[])
       {
          for (int x =0;  x <10; x++)
	   {
	      for (int y =x; y >=0; y--)
	   {
	      
	   	  System.out.print(y);
	   }
          System.out.println();
	   
	   }
       }
       }

/////

Thanks for that contribution *sarcasm*

hi i need to create a program that will count for vowel and consonant in a string

commented: what's stopping you? -2

If you have question create new thread don't try to hijack one from 2007.
Read the notice at the top of the Java forum main page "We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well."
So do some work and if you get stuck start a new thread. Don't even think of starting a post with "i need to create a program..." if you don't want a torrent of sarcasm & abuse.

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.