Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void HistogramArray(int arr1)
- {
- int i, s, num = 0; // declaring and initialize variables
- int new_arr[21] = { 0 }; // declaring and initialize a new array
- for (i = 0; i < 14; i++)
- { // start of the first loop //
- num = arr1[i]; // copy the content //
- new_arr[num] = s++; // save the amount of times that the number is written //
- } // end of the first loop //
- printf("\nValue\tHistogram\n"); // inform the user //
- for (i = 0; i < 20; i++)
- { // start of the external printing loop - printing numbers //
- if (new_arr[i] != 0)
- { // only if the numbers appeared in the original array //
- printf("\n%d\t", i); // print the numbers between 1 - 20 //
- while (new_arr[i] != 0)
- { // start of the inner printing loop - printing stars //
- printf("*");
- s--;
- } // end of the inner printing loop //
- } // end of the 'if' term //
- } // end of the external printing loop //
- } // end of function //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement