Basically I have to do the exercise is as follows - A function DisplayListAsBarChart that may be passed an array of values. The function
should then display the array of values as a bar-chart.
This is what I have so far but when I compile it, bars start showing up like
this
1 |
4 | || ||
7 || || |||
can someone outline what I'm doing wrong and the solution would be appreciated too.
Strange that you got output, when I compiled and runned this it crashes because DisplayListAsBarChart is called with an uninitialized array.
So I would start with moving the call to DisplayListAsBarChart out of the for loop, so the array is properly initialized.
Then I would remove the "using namespace std;" because the variable list that you use is a reserved word in the namespace std. In general I would recommend to not use "using namespace std;" until you are familiar with every function and keyword in the standard library (which equals never).
Subsequently I would think that you should think about what a row is and what a column is in your graph. Specifically: when you start to use std::cout each row in your graph table is a single line in the console.