Answer to Question #252175 in C for sparwqne

Question #252175

Write a C program that read numbers from an integer array and graph the information in the

form of bar chat. Sample output is given below.

Element Value Histogram

0 19 *******************

1 3 ***

2 15 ***************

3 7 *******

4 11 ***********

5 9 *********

6 13 *************

7 5 *****

8 17 *****************

9 1 *


1
Expert's answer
2021-10-16T13:53:16-0400
#include <stdio.h>

int main()
{
  int arr[] = { 19, 3, 15, 7, 11, 9, 13, 5, 17, 1 };
  int size = sizeof(arr) / sizeof (arr[0]);
  for (int i = 0; i < size; i++) {
    printf("%d %d ", i, arr[i]);
    for (int j = 0; j < arr[i]; j++) {
      printf("*");
    }
    printf("\n");
  }
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS