• Post Reply Bookmark Topic Watch Topic
  • New Topic

Printing Array  RSS feed

 
mike statham
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • 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
 
Liutauras Vilda
Sheriff
Posts: 4927
334
BSD
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Likes 2
  • Mark post as helpful
  • send pies
  • 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
  • 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: 4927
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show us mike how did you solve it. We want to see it too.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!