Formatting help please

Nov 28, 2018 at 1:10pm
Need some pointers in formatting some code.
Im doing an assignment that prints the element, value and histogram of an array.

I have the code sorted, but I cant figure out where to put the for loop in order to place it under the correct title.

Last edited on Dec 9, 2018 at 12:17pm
Nov 28, 2018 at 2:44pm
So... you want to print out a histogram once for every i,j combination? If so, then it looks to me that the for loop is in the right place.

Can you be more specific about what your problem actually is? What is it that your program is doing that seems wrong to you?
Nov 28, 2018 at 2:52pm
Well once you run the program, the histograms are actually printing before every thing else.
But the way that my "table" is formatted and required by the conditions, means that it should be printed last, in a neat column.
i.e.
Element Value Histogram
00 4 ****
01 3 ***

etc.etc.

So my trouble is actually getting it in the right place format wise.
Nov 28, 2018 at 3:01pm
So this is purely about formatting?

If you want to output the the histogram after the other information in the row, then... just move the code that outputs it to after the code that outputs the things that come before it.

Currently, for each row, you do:

- output histogram (using loop)
- output [i][j]
- output value of the element
- output an endline

Just re-arrange the order of those things until they're what you want them to be, i.e.

- output [i][j]
- output value of the element
- output histogram (using loop)
- output an endline
Last edited on Nov 28, 2018 at 3:01pm
Nov 28, 2018 at 3:07pm
YES MIKEY!

Thank you so much

It was the last line you put
-output an endline

Thats where I was messing up so badly..
such a simple thing yet it fixed everything.

Thank you again!
Nov 28, 2018 at 3:20pm
No problem! I kinda suspected that might have been the bit you'd forgotten to change when you were changing the order of lines :) Glad I could help!
Topic archived. No new replies allowed.