bar graph help

This is a discussion on bar graph help within the C Programming forums, part of the General Programming Boards category; Hi all, just a quick question. How can i take a user inputed int and convert that to a visual ...

  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
    Registered User
    Join Date
    Oct 2011
    Posts
    889
    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, 02: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, 11:57 PM
  5. Graph possible for c++ ??
    By joeyzt in forum C++ Programming
    Replies: 2
    Last Post: 06-28-2003, 09:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21