Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C programming needed Introduction Finish a program that it generate a histogram of the values stored in an array. A histogram counts the number of

C programming needed

Introduction

Finish a program that it generate a histogram of the values stored in an array. A histogram counts the number of times a specific value occurs in an array and stores the counted value in a new array at the location of the number that was counted. The following illustrates an example of an input array storing values between 0 and 9.

Sample input array: {1, 1, 2, 3, 1, 2, 2, 3, 1, 1, 5, 6, 7, 8, 9, 9, 8, 6, 5, 5}

Output histogram: int hist[10] = {0, 5, 3, 2, 0, 3, 2, 1, 2, 2}

Instructions

In this program, you should

ask user for the amount of numbers between 0-9 that the user is going to input;

declare an array of the that amount of integers;

ask user to input the numbers between 0-9 one by one and store it in the array;

calculate the histogram array according to the values in the array you have just stored;

print the content of the array.

Assume that user will input correct data and do not implement any input validation.

Sample run 1 input/output (you should see this when you run your code interactively on your PC)

Input the amount of values: 10 Input the values between 0 and 9 (separated by space): 1 0 6 1 5 0 7 9 0 7 Your histogram: 0 - 3 1 - 2 2 - 0 3 - 0 4 - 0 5 - 1 6 - 1 7 - 2 8 - 0 9 - 1 

This output means number 0 appeared 3 times, number 1 appeared twice, etc.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions