Hi everyone,
I have just started to learn java, nd started to work on some nice little programs but was trying to develop a output similar to this following

1
121
1331
14641


but couldnt make it.... instead i ended up to give this folloiwng output
1
12
123
1234
123
12
1

Any help would be highly appreciated

Thnx in advance

Well, seeing your code would be a good starting point. And use code tags

Well, seeing your code would be a good starting point. And use code tags

A little suggestion about making the code would really help me....

Thnx in advance

Like I said, lets see what you have. I am not just simply going to do it for you.

I will help you correct yours, but in order to do it, I need to see it. If you're not willing to show it, them I will have to assume that you "made up" that output that you suppossedly got and are just fishing for someone to do your homework for you.

masijade.Statement()=true;
you need to post your code so that switch(we can){
case a:
    find out where you goofed;
    break;
case b:
    know you're not just getting Daniweb to do your work for you;
    break;
}
while(stillConfused()){
    recommendVenomlash="nCr";
}

:icon_cheesygrin:

seriously...GID*


*Get It Done (courtesy of Chris Livatino)

ok.... sorry for not posting up the code
here is the code i did

public class prog8{
public class static void main(String args [])
{
int i,z=1,j=1;
// loop for running it 4 times
for(i=0;i<5;i++)
{
System.out.print(z);
// after printing 1 it shuld go to next line then it shuld print 1 then move to next cursor and print z+1
for(int x=0;x<i;x++)
{
System.out.println("");
System.out.print(z);
z++;
}
}
}
}

But ended up with this following result

11
12
2
34
4
5
67
7
8
9
10

public class prog8{
public class static void main(String args [])

Something tells me that putting class in twice may not be doing you a whole lot of good.;)

Apart from that, I can't tell. Fix the double class goof and then report back at 0800, cadet. Dismissed.

Write down what your exact requirements are, then, in words, try to describe what you think you need to do in order to arrive at that point.

Until you sit back, concentrate, and do this step, you are just poking around in the dark. No offense intended, but that is exactly what that code above is doing. You haven't designed a real plan of attack (and possibly do not have a clear understanding of what is needed), and so you have just thrown something together on the off chance that you might get lucky.

So, as mentioned, sit back and write out exactly what the requirements are and what you think you need to do to arrive at that point. Then make another attempt at programming it. If it still doesn't work, then post all three of the above mentioned items here, and we will help you further.

Ok... as u say sir, let me explain what i think for this coding

I need an output 
     1
   121
  1331
 14641
151051 and so on

so as my thinking its like first u intialize one n=1 so intially printing 1 will do and then moving to the new line will also happen at the run time of program....
Next line will start with 1 and end with 1, the middle number would be addtion of n+1
The third line would be addtion of above line ie. 1,(1+2),(2+1),1
and so on

for 3rd line it wuld be: 1,(1+3),(3+3),(3+1),1
for 4th line it wuld be 1,(4+1),(4+6),(4+1),1

and now you put that into code.
And when you've done that and it actually works (instead of pasting something you pilfered out of a newsgroup or website without actually seeing if it does anything close to what you're supposed to do), you try to make it look like you want it to.

It's very easy, far easier than anything you're likely to have to do if you ever get a job doing anything at all requiring any intelligence.
So if you can't even pull this off you might start training your wrist to flip burgers without throwing them on the floor as that'll be the highest paying job you'll be capable of.

Ok... as u say sir, let me explain what i think for this coding

I need an output 
     1
   121
  1331
 14641
151051 and so on

so as my thinking its like first u intialize one n=1 so intially printing 1 will do and then moving to the new line will also happen at the run time of program....
Next line will start with 1 and end with 1, the middle number would be addtion of n+1
The third line would be addtion of above line ie. 1,(1+2),(2+1),1
and so on

for 3rd line it wuld be: 1,(1+3),(3+3),(3+1),1
for 4th line it wuld be 1,(4+1),(4+6),(4+1),1

Very good, two points out of three, now as jwenting said, try putting that into code, which was the third point. If you really have problems with it, they can be overcome. Comment nearly everyline that actually does something, with what it is suppossed to do, if you have to. That way, you will immediately be able to tell if what you are doing is actually bringing you closer to your goal.

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.