C program – Bar Graph

by Nideesh C on April 17, 2011 · 0 comments

in C Programming




#include<graphics.h>
#include<stdio.h>
#include<math.h>
#include<dos.h>
#include<conio.h>
 
void main()
{
	int i,n,a,b;
	void drawrect(int ,int);
 
	int graphdriver = DETECT, graphmode;
	initgraph(&graphdriver, &graphmode, "..\\bgi");
 
	setcolor(CYAN);
	printf("ENTER THE NUMBER OF DATA ELEMENTS\n");
	scanf("%d",&n);
 
	line(1,1,1,479);// Y axis
	line(1,479,640,479);// X axis
 
	for(i=1;i<=25;i++)
	{
		outtextxy(40*i,470,"|");
		outtextxy(1,479-40*i,"-");
	}
 
	printf("ENTER X AND Y CO-ORDINATES \n");
	for(i=1;i<=n;i++)
	{
		scanf("%d %d",&a,&b);
		b--;
		drawrect(a*40,b*40);
	}
	getch();
	closegraph();
}
 
void drawrect(int a,int b)
{
	 setfillstyle(SOLID_FILL,CYAN);
	 bar3d(a,478,a,430-b,5,1);
}



Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C Program – Display a line graph using midpoint line algorithm.
  2. C program – Spiral Model
  3. Sample – Program to construct a 3-dimensional bar.
  4. C Program – Create a house and perform the operations.
  5. C Program – Draw a rectangle and perform the operations.

Leave a Comment

Previous post:

Next post: