Thursday, 15 December 2011

How to make a graphical stopwatch with C & C++ graphics

How to make a graphical stopwatch with C & C++ graphics
You can make your own stopwatch if you know about C & C++ language. Following is an easy and simple stopwatc code and some links. You can select one of them and run it into your compiler.






#include
#include
#include
#include
#include
#include
#include

  void stpshp();

  void main()
  {clrscr();
  int gdriver = DETECT, gmode;
  initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
  stpshp();
  int h=1,mm=2,ss=3,ms=4;


      for(h=0; h<60; h++)
      {
for(mm=0;mm<60; mm+=1)
{ for(ss=0; ss<60; ss+=1)
  { for(ms=0; ms<60; ms+=1)
     {
      gotoxy(22,9);
      cout<
      gotoxy(37,9);
      cout<
      gotoxy(51,9);
      cout<
      gotoxy(37,11);
      cout<
      delay(16.9);
      if(kbhit())
      {break;}
    }
      if(kbhit())
      {break;}
     }
if(kbhit())
      {break;}
     }
if(kbhit())
      {break; }
     }
 getche();
 }

void stpshp()
 {
  setcolor(RED);
  settextstyle(4,0,6);
  outtextxy(160,4,"Stop Watch");
  rectangle(90,10,530,70);
/////////////////////////////////////////////////////////////////////
  settextstyle(0,0,0);
  rectangle(130,120,460,155);
  rectangle(130,120,240,155);
  rectangle(240,120,350,155);
  rectangle(240,155,350,190);

  outtextxy(145,110,"Hours");
  outtextxy(255,110,"Minuts");
  outtextxy(370,110,"Seconds");
  setcolor(RED);
  rectangle(10,425 ,620,477);
  settextstyle(0,0,1);
  outtextxy(16,430,"NAME: Muhammad Waqas");
  outtextxy(16,445,"Roll # 9275");
  outtextxy(16,460,"Class : BCs-A(2011 - 2014)");
  outtextxy(400,430,"S u b m e t t e d  T o");
  outtextxy(380,460,"S i r .  U m e r  H a y a t");
  settextstyle(4,0,16);
  outtextxy(30,90,"V      V");

   }





Hope you like it. Thanks cpptechnology will upload more easy and interesting  C & C++ programs for you. So keep visiting and learning.

No comments:

Post a Comment