Hi, i'm a total beginner for C++ and for my tutorial exercise i have been told to create a histogram (a question like this may come up in the exam as i been told).
Anyway i understand you need to assign arrays to create a histogram and that is the only thing i know.
My programe is basically about benchmarks, 20 different programes and the user has to input them giving them marks out of 100 and each star in the histogram represents the mark it recieved. The histogram should look something like this.
0-29 **
30-39 ***
40-69 *************
70-100 **
Anyways, i'm not asking the helpers on this forum to create the programe for me or give me the codes all i'm asking is what steps do i take inorder to create the histogram like for e.g. how can a user input a mark (28) and it will show up in the histogram?
P.S All i understand i i need to create 4 loops but i don't know how will i do them and how will a user input the marks in order for the start to show up in the histogram.
for(size_t i = 0; i < 20; ++i)
cin>>your score
std::sort(your container)
position = find_if(> 30);
range_0_29 = distance(begin of your contianer, position);
.........
you don't need to assign the marks into the arrays
you only need to count how many scores within the specific range
and output the stars according to the number of the scores
1 2
for(size_t i = 0; i < range_0_29; ++i)
cout<<"*";
something like that
ps : there are many ways to solve this problem
the way I stated are not very good since it is a little bit complicated
you could use an easier way to solve this problem