• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Printing Array

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Which produces:
1 thru 1
2 thru 2
3 thru 3
4 thru 4
5 thru 5
6 thru 6


I've search the wrong books or what to search on the net to figure away or how to the following output:
1 thru 10
11 thru 20
21 thru 30
31 thru 40
41 thru 50
51 thru 60


Can some one give a clue or a place to look, driving me nuts
 
Sheriff
Posts: 8544
615
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi mike,

This execise it seems has nothing to do with Arrays, at least now.

So, what kind of facts do you know?
1. You need to print out 6 lines
2. Each time, your counter is being increases by 10.
a) left hand side counter starts from 1
b) right hand side counter starts from 10

There are more than one way to solve this exercise. One way could be to use "i" only for loop iteration, and other variables you could use for printing values out. One initialize to x (number) and the other to y (number), and each iteration increment by z (number) and print out. Could you? Or you have some kind of restrictions in this exercise?

 
mike statham
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No I have no restrictions on this exercise. I wrote the program last week and got 18 out of 25, miss putting a priority to the right level and this part.
I originally printed out "AA thru BB" 6 times instead of what I need now.
 
Bartender
Posts: 3323
86
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looking at the second value first (because it's easier) what do you have to do to change 1, 2, 3 ,4 ,5 ,6 to 10, 20, 30 ,40 ,50 ,60. If you are thinking multiply by 10 then you are right. So you could simply change your print statement to

Now using the same logic what do you have to do to the first number to change 1, 2, 3 ,4 ,5 ,6 to 1, 11, 21, 31 ,41 ,51?
 
mike statham
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Guess overthinking the problem was my biggest problem. I just figured it was something more complex.

Thanks for the information.


 
Liutauras Vilda
Sheriff
Posts: 8544
615
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please show us mike how did you solve it. We want to see it too.
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic