making graphs in C

This is a discussion on making graphs in C within the C Programming forums, part of the General Programming Boards category; does anyone here know the simplest way to make graphs in C?coz im planning to make a millionaires game with ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    28

    making graphs in C

    does anyone here know the simplest way to make graphs in C?coz im planning to make a millionaires game with a graph that will somehow display the percentage of the audience choice of a particular answer:like a.50% b.25% c.15% d.10%????

    if possible pls show the code on how to make it coz im a bit confused with how for loops are to be used here???
    only the fittest survive!!!

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    28

    Lightbulb

    uhm..all i know is that im usin Linux C compiler.......i was wonderin how to make exact code for the graphs which i was told that can be done usin some loops???
    Last edited by kreyes; 03-01-2002 at 08:49 PM.
    only the fittest survive!!!

  3. #3
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    What Salem is saying is that for Graphics, you need a library and/or API because you can't just do this. I'm not familiar with Linux programming, so I can't help you out there...
    1978 Silver Anniversary Corvette

  4. #4
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    It's possible to make a histogram if you use 'x' to shade in. I guess you would want a pie chart though.

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    28

    Unhappy

    Originally posted by Nick
    It's possible to make a histogram if you use 'x' to shade in. I guess you would want a pie chart though.
    ummm,can you like make a sample source code of that coz im kinda a newbie??pls.
    only the fittest survive!!!

  6. #6
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    
    #define N 70
    #define MAX_BLOCKS 22
    
    void create_sin_distr(double freq[], int n)
    {
        int i;
        for (i = 0; i < n; ++i)
            freq[i] = fabs(sin((4.0 * M_PI * i)/n));
    }
    
    int main(void)
    {
        int i, j;
        double freq[N];
        int blocks[N];
        
        create_sin_distr(freq, N);
        for (i = 0; i < N; ++i)
            blocks[i] = MAX_BLOCKS * freq[i];
        
        for (i = MAX_BLOCKS; i >= 1; --i) {
            for (j = 0; j < N; ++j) {
                if (blocks[j] >= i)
                    putchar('X');
                else
                    putchar(' ');
            }
            putchar('\n');
        }
    
        return 0;
    }

  7. #7
    Registered User
    Join Date
    Mar 2002
    Posts
    28

    Graphics

    if u wanna play w/ graphics under linux use ncurses.h

    named appropriate 'cause u'll calling a few curses while trying to code it.

    but if u wanna keep it simple...just print a char so many times at location x,y

    the x idea isn't bad...

    it gets the job done.
    curiousity killed the cat, but it
    makes for one hell of a programmer.

    Alien.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. making sprites
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 02-20-2010, 07:00 AM
  2. Making great graphics
    By MadCow257 in forum Game Programming
    Replies: 1
    Last Post: 02-20-2006, 11:59 PM
  3. Making control...
    By Finchie_88 in forum C++ Programming
    Replies: 2
    Last Post: 09-07-2004, 02:42 PM
  4. Replies: 2
    Last Post: 01-13-2003, 01:28 PM
  5. About Unix Programming - Making a career desision
    By null in forum C Programming
    Replies: 0
    Last Post: 10-14-2001, 08:37 AM

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