Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 function
void 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]