Write the full source of a program using the function void bar_chart(double valu
ID: 3637119 • Letter: W
Question
Write the full source of a program using the functionvoid bar_chart(double values[], int size)
that displays a bar chart of the values in values, using asterisks, like this:
**********************
****************************************
****************************
**************************
**************
You may assume that all values in values are positive or negative. First figure out the maximum
value in values. That value’s bar should be drawn with 40 asterisks. Shorter bars
should use proportionally fewer asterisks.
Explanation / Answer
#include #include using namespace std; void bar_chart( double values[], int size ) { int i; static string s = "**************************************************"; // Set max & min to -infty and +infty, respectively double max = numeric_limitsmin(); double min = numeric_limitsmax(); for( i=0; i max ) max = values[i]; if ( values[i]Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.