Thread: Histogram Assignment..HELP

  1. #1
    Registered User
    Join Date
    Oct 2016
    Posts
    1

    Histogram Assignment..HELP

    Hi, I'm a 12th grade student and we've been doing arrays recently. Our teacher gave us a homework assignment to Accept 50 values from the user between 0 and 5. Print a histogram to represent the values and print the frequency of each value.

    Prompting for, accepting and storing the values within the array is simple. I just don't know how to print a histogram.

    Thanks in advance for your help.

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Well there are a couple of ways to do it. With a horizontal histogram and such a small number of votes, you can simply output one star for one vote. You'd end up with something like this.

    0 | ***
    1 | *****
    2 | ********************
    3 | **********
    4 | ***
    5 | *********

    A vertical histogram is the same way, but it is slightly more complicated by the orientation. You are still printing like the way you write, from left to right, not top to bottom, so you will have to be careful not to print too many stars.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Write a histogram of word length (K&R 1.13 assignment)
    By Dino Sylence in forum C Programming
    Replies: 1
    Last Post: 04-16-2015, 02:10 AM
  2. Histogram
    By SpecKROELLchen in forum C Programming
    Replies: 9
    Last Post: 08-02-2012, 03:10 AM
  3. Histogram help
    By Fixxxer in forum C Programming
    Replies: 4
    Last Post: 11-12-2010, 02:15 AM
  4. histogram
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 04-04-2007, 12:25 PM
  5. Histogram
    By fjf314 in forum C++ Programming
    Replies: 1
    Last Post: 01-15-2004, 11:39 PM

Tags for this Thread