Q:

Write a C program to implement Bar Graph in Graphics

0

Write a C program to implement Bar Graph in Graphics. Here’s simple program to implement Bar Graph in Graphics in C Programming Language.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Below is the source code for C program to implement Bar Graph in Graphics which is successfully compiled and run on Windows System to produce desired output as shown below :

 
 


SOURCE CODE : :

/*  C program to implement Bar Graph in Graphics  */

#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);
}

Above is the source code for C program to implement Bar Graphs in Graphics which is successfully compiled and run on Windows System.The Output of the program is shown above .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Graphic Solved Programs – C Programming

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a C Program to implement Kite flying in Grap... >>
<< Write a C program to implement Spiral Model in Gra...