Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

please provide solution:

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CAN ANY BODY HELP ME OUT IN THIS PROBLEM.I WANT TO PRINT THE BELOW FORMAT
ON THE SCRREN.PLEASE HELP ME WITH THE LOGIC TO SOLVE IT

1
2 3
4 5 6
7 8 9 10
[ August 05, 2007: Message edited by: raghu rajan ]
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all please KeepItDown.

The simplest solution would be:


What does the first code you tried look like?

See also:
DoYourOwnHomework
[ August 05, 2007: Message edited by: Garrett Rowe ]
 
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by raghuram vardharajan:
CAN ANY BODY HELP ME OUT IN THIS PROBLEM.I WANT TO PRINT THE BELOW FORMAT
ON THE SCRREN.PLEASE HELP ME WITH THE LOGIC TO SOLVE IT

1
2 3
4 5 6
7 8 9 10

[ August 05, 2007: Message edited by: raghu rajan ]



You need an int variable to store the number of rows you want to print. A main loop will check against exceeding this value.

Another int variable is needed to store the current value being printed (this will be incremented after each print).

And finally, an int variable is needed to store the current row being printed (incremented after each row is printed).

In printing a row you use a for loop - from 1 to current row #. The for loop will use System.out.print() and System.out.println().
 
raghu ram
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
smith can your procedure be applicable to n rows,such that if we
pass n=4
then we should be able to print
1
23
456
789 10 and if n=5
1
23
456
789 10
11 12 13 14 15
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, raghu ram. All you need to do is take the logic Red Smith has suggested and add a loop round it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic