Nov 21, 2011

C Program to generate Graph using grphics.h

C Program to Generate the graph sheet using the grphics.h library. To use graphics.h, we have to install the drivers in to the the system by using the initgraph() function. Here  we derive the graph of input sizes verses time taken for input sizes. x axis represents inputs(0,10000,20000,----), y axis rep time(0,0.05,0.1,0.15---). Read more about C Programming Language.
* You can use all the programs on
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact
* To find more C programs, do visit
* and browse!
*                      Happy Coding

#include "stdio.h"
#include "conio.h"
#include "graphics.h"
void main() {
 int gd = DETECT, gm;
 int y = 0, x = 10, m[20], k[20], n, a[20], i;
 float b[20];
 initgraph(&gd, &gm, "c:\\tc\\bgi");
 printf("\n\n\tGenerating the Graphs\n\n");
 printf("\nEnter the no. of inputs\t");
 scanf("%d", &n);
 printf("\nEnter the input sizes and corresponding time taken\n");
 for (i = 0; i < n; i++) {
  printf("\nEnter input size\t");
  scanf("%d", &a[i]);
  printf("\nEnter time taken\t");
  scanf("%f", &b[i]);
 //represents y axis
 line(10, 0, 10, 400);
 //represents x axis
 line(10, 400, 600, 400);
 while (y <= 400) {
  line(0, y, 10, y);
  y = y + 20;
 while (x <= 600) {
  line(x, 400, x, 410);
  x = x + 20;
 outtextxy(20, 440, "1unit=20 pixels , origin is (10,400)");
   "x axis represents inputs(0,10000,20000,----), yaxis rep time(0,0.05,0.1,0.15---)");
 for (i = 0; i < n; i++) {
  k[i] = (a[i] * 0.002);
  m[i] = (400 - (b[i] * 400));
  putpixel(k[i], m[i], 11);
 for (i = 0; i < n - 1; i++)
  line(k[i], m[i], k[i + 1], m[i + 1]);
Read more Similar C Programs
Learn C Programming

Number System

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!
To browse more C Programs visit this link