Question
16.3 Homework 2a : Text-based histogram (c++) Arrays are one of the fundamental data structures in computer science. This homework is designed to get you
16.3 Homework 2a : Text-based histogram (c++)
Arrays are one of the fundamental data structures in computer science. This homework is designed to get you working with 1 and 2 dimensional arrays in C++. There are 2 problems in this homework.
Related C++ HackerRank Problems
Introduction -> For Loop
Introduction -> Arrays Introduction
Introduction -> Variable Sized Arrays
Problem 2a : Text-based Histogram
Write a program to generate a text-based histogram for a quiz given to a class of students. The quiz is graded on a scale from 0-10. Write a program that allows the user to enter grades for each student. As the grades are being entered, the program should count, using an array, the number of grades of each value. The user indicates the end of the input by a negative number. The program should be capable of handling an arbitrary number of student grades.
When printed, the histogram should show the grade value, followed by X's for the number of grades for each score, followed by the actual number in parentheses.
Sample program run
Enter each grade and a negative number to stop: 0 0 1 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 5 5 5 5 -1 Histogram of grades: 0: XX (2) 1: X (1) 2: (0) 3: XXXXXXXXXXX (11) 4: XXXX (4) 5: XXXX (4)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started