Frooster

Bar Graph

May 17th, 2015
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.84 KB | None | 0 0
  1. /* ========this is a basic design of construction of a bar graph======*/
  2.     //+++++++++++++++++++++BY RAM++++++++++++++++++++++
  3.     //after which you can design and decide upon your own
  4.  
  5. /* this program outputs a bar graph after accepting the values for the height of he graph .
  6.  
  7. First the x and y axis of the graph is displayed
  8. Values are accepted for the height of the graph and accordingly the height of the graph is displayed
  9.  
  10.  
  11. Runs exclusively in Turbo c++
  12. */
  13.  
  14.  
  15.  
  16.  
  17. #include<iostream.h>
  18. #include<conio.h>
  19. #include<dos.h>
  20. #include<graphics.h>
  21. #include<stdlib.h>
  22.  
  23. void main()
  24. {
  25. clrscr();
  26. int gdriver=DETECT,gmode;
  27.   initgraph(&gdriver,&gmode,"C://TC//bgi");
  28.  
  29.  
  30.  line(10,10,10,300);//vertical line
  31.  line(5,300,320,300);//horiz line
  32.  
  33.   /*=====marking on the bottom of the bar graphs=========*/
  34.  outtextxy(20,310,"0");
  35.  outtextxy(40,310,"10");
  36.  
  37.  outtextxy(60,310,"20");
  38.  outtextxy(80,310,"30");
  39.  
  40.  outtextxy(100,310,"40");
  41.  outtextxy(120,310,"50");
  42.  
  43.  outtextxy(140,310,"60");
  44.  outtextxy(160,310,"70");
  45.  
  46.  outtextxy(180,310,"80");
  47.  outtextxy(200,310,"100");
  48.  
  49.  settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);//x axis text
  50.  outtextxy(10,325,"X-AXIS(whatever you want)");
  51.  
  52.  settextstyle(DEFAULT_FONT,VERT_DIR,1);  //y axis text
  53.  outtextxy(10,70,"Y-AXIS(10 TO 300)");
  54.  
  55.  setcolor(GREEN);
  56.  setfillstyle(SOLID_FILL,RED);//the heading box white
  57.  bar(300,10,440,50);
  58.  
  59.  settextstyle(SANS_SERIF_FONT,HORIZ_DIR,3);//text of bar graph heading
  60.  outtextxy(305,15,"BAR GARPH");
  61.  
  62.  setcolor(WHITE);
  63.  rectangle(299,11,441,51);//outline of the heading
  64.  
  65.   setcolor(BROWN);
  66.  settextstyle(TRIPLEX_FONT,HORIZ_DIR,2);
  67.  outtextxy(455,10,"(basic design)");
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  /*=============BAR GRAPH CONSTRUCTION==============*/
  74.  
  75.  int ch;//variable for 1st bar height
  76.  
  77.  gotoxy(50,5);
  78.  cout<<"enter the height of the bar"<<endl;
  79.  gotoxy(50,6);
  80. cin>>ch;//height of 1st bar graph
  81.  
  82.   setcolor(GREEN);
  83.   setfillstyle(SOLID_FILL,GREEN);
  84.  bar(20,ch,40,300);//1st bar graph
  85.  
  86.  
  87.  int ch1;//variable for 2nd bar height
  88.   gotoxy(50,10);//apapearence of the instruction for 2nd bar graph
  89.  cout<<"enter the height of 2nd bar"<<endl;
  90.  gotoxy(50,11);
  91.  cin>>ch1;
  92.  setfillstyle(SLASH_FILL,MAGENTA);
  93.  bar(50,ch1,70,300);//2nd bar graph
  94.  
  95.  int ch2;//variable for 3rd bar height
  96.  gotoxy(50,13);
  97.  cout<<"enter the height of 3rd bar"<<endl;
  98.  gotoxy(50,14);
  99.  cin>>ch2;
  100.  setfillstyle(XHATCH_FILL,BLUE);
  101.  bar(80,ch2,100,300);//3rd bar graph
  102.  
  103.  int ch3;//variable for 4th bar height
  104.  gotoxy(50,17);
  105.  cout<<"enter the height of 4th bar"<<endl;
  106.  gotoxy(50,18);
  107.  cin>>ch3;
  108.  setfillstyle(HATCH_FILL,BLUE);
  109.  bar(110,ch3,130,300);//4th bar graph
  110.  
  111.  int ch4;//variable for 5th bar height
  112.  gotoxy(50,21);
  113.  cout<<"enter the height of 5TH bar"<<endl;
  114.  gotoxy(50,22);
  115.  cin>>ch4;
  116.  setfillstyle(LINE_FILL,YELLOW);
  117.  bar(140,ch4,170,300);//3rd bar graph
  118.  
  119.  getch();
  120.   closegraph();
  121.  }
Advertisement
Add Comment
Please, Sign In to add comment