Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ========this is a basic design of construction of a bar graph======*/
- //+++++++++++++++++++++BY RAM++++++++++++++++++++++
- //after which you can design and decide upon your own
- /* this program outputs a bar graph after accepting the values for the height of he graph .
- First the x and y axis of the graph is displayed
- Values are accepted for the height of the graph and accordingly the height of the graph is displayed
- Runs exclusively in Turbo c++
- */
- #include<iostream.h>
- #include<conio.h>
- #include<dos.h>
- #include<graphics.h>
- #include<stdlib.h>
- void main()
- {
- clrscr();
- int gdriver=DETECT,gmode;
- initgraph(&gdriver,&gmode,"C://TC//bgi");
- line(10,10,10,300);//vertical line
- line(5,300,320,300);//horiz line
- /*=====marking on the bottom of the bar graphs=========*/
- outtextxy(20,310,"0");
- outtextxy(40,310,"10");
- outtextxy(60,310,"20");
- outtextxy(80,310,"30");
- outtextxy(100,310,"40");
- outtextxy(120,310,"50");
- outtextxy(140,310,"60");
- outtextxy(160,310,"70");
- outtextxy(180,310,"80");
- outtextxy(200,310,"100");
- settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);//x axis text
- outtextxy(10,325,"X-AXIS(whatever you want)");
- settextstyle(DEFAULT_FONT,VERT_DIR,1); //y axis text
- outtextxy(10,70,"Y-AXIS(10 TO 300)");
- setcolor(GREEN);
- setfillstyle(SOLID_FILL,RED);//the heading box white
- bar(300,10,440,50);
- settextstyle(SANS_SERIF_FONT,HORIZ_DIR,3);//text of bar graph heading
- outtextxy(305,15,"BAR GARPH");
- setcolor(WHITE);
- rectangle(299,11,441,51);//outline of the heading
- setcolor(BROWN);
- settextstyle(TRIPLEX_FONT,HORIZ_DIR,2);
- outtextxy(455,10,"(basic design)");
- /*=============BAR GRAPH CONSTRUCTION==============*/
- int ch;//variable for 1st bar height
- gotoxy(50,5);
- cout<<"enter the height of the bar"<<endl;
- gotoxy(50,6);
- cin>>ch;//height of 1st bar graph
- setcolor(GREEN);
- setfillstyle(SOLID_FILL,GREEN);
- bar(20,ch,40,300);//1st bar graph
- int ch1;//variable for 2nd bar height
- gotoxy(50,10);//apapearence of the instruction for 2nd bar graph
- cout<<"enter the height of 2nd bar"<<endl;
- gotoxy(50,11);
- cin>>ch1;
- setfillstyle(SLASH_FILL,MAGENTA);
- bar(50,ch1,70,300);//2nd bar graph
- int ch2;//variable for 3rd bar height
- gotoxy(50,13);
- cout<<"enter the height of 3rd bar"<<endl;
- gotoxy(50,14);
- cin>>ch2;
- setfillstyle(XHATCH_FILL,BLUE);
- bar(80,ch2,100,300);//3rd bar graph
- int ch3;//variable for 4th bar height
- gotoxy(50,17);
- cout<<"enter the height of 4th bar"<<endl;
- gotoxy(50,18);
- cin>>ch3;
- setfillstyle(HATCH_FILL,BLUE);
- bar(110,ch3,130,300);//4th bar graph
- int ch4;//variable for 5th bar height
- gotoxy(50,21);
- cout<<"enter the height of 5TH bar"<<endl;
- gotoxy(50,22);
- cin>>ch4;
- setfillstyle(LINE_FILL,YELLOW);
- bar(140,ch4,170,300);//3rd bar graph
- getch();
- closegraph();
- }
Advertisement
Add Comment
Please, Sign In to add comment