Thread: bar graph help

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    7

    bar graph help

    Hi all, just a quick question. How can i take a user inputed int and convert that to a visual repercenitive for a bar graph? like if the user inputs a "5", how can i convert that to ***** or #####. Basically im trying to make a bar graph and im losing my mind. lol

  2. #2
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    A loop?
    Code:
    int  user_input = the number you got from the user;
    int  i;
    
    /* Output a horizontal "bar" of user_input #'s, */
    for (i = 0; i < user_input; i++)
        putchar('#');
    
    /* then a newline to move to the start of next line. */
    putchar('\n');
    Are you sure you haven't skipped class?

  3. #3
    Registered User
    Join Date
    Oct 2012
    Posts
    7
    lol not a single day. ever since we went over functions i've been a little lost.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. graph.h
    By spime in forum C Programming
    Replies: 10
    Last Post: 11-04-2008, 02:22 PM
  2. need help with sin(x) and bar graph
    By SuPaNooB in forum C Programming
    Replies: 6
    Last Post: 10-07-2007, 01:01 AM
  3. need graph.h
    By h_howee in forum Windows Programming
    Replies: 3
    Last Post: 12-17-2005, 05:36 PM
  4. Graph
    By fkheng in forum C Programming
    Replies: 8
    Last Post: 07-05-2003, 10:57 PM
  5. Graph possible for c++ ??
    By joeyzt in forum C++ Programming
    Replies: 2
    Last Post: 06-28-2003, 08:00 PM