Saturday, 17 December 2011

Graphical Table writer with C & C++ graphics


Friends this is a code for graphical calculator. You can run this c++ code with your compiler and enjoy it. This is a so simple and beautiful project code for you. So, Run it and give me your feedbacks. Thanks

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

 ///////////////////////
  int xft1=170,xft2=190,chf1=0,chf2=0,ex1=0,ex2=0;

  void tblshp();

  void main()
  {
  int gdriver = DETECT, gmode;
  initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
  int tn,ts,te,i,ps=0;
  char ch;
  tblshp();
 gotoxy(23,9);
 cin>>tn;
 gotoxy(37,9);
 cin>>ts;
 gotoxy(50,9);
 cin>>te;
    for(i=ts; i<=te; i++)
 {  ps++;
   gotoxy(29,11+ps);
   cout<
   }

  getche();

  }

void tblshp()
{

  setcolor(RED);
  settextstyle(4,0,6);
  outtextxy(160,4,"T A B L E");
  rectangle(90,10,530,70);
/////////////////////////////////////////////////////////////////////
  settextstyle(0,0,0);
  rectangle(130,120,460,155);
  rectangle(130,120,240,155);
  rectangle(240,120,350,155);
  outtextxy(145,110,"Table no");
  outtextxy(255,110,"First limit");
  outtextxy(370,110,"Last limit");
  rectangle(180,xft1,430,xft2+300);
  settextstyle(4,0,16);
  outtextxy(30,180,"T      T");

  }



Friday, 16 December 2011

Graphical Temperature Converter C & C++ code

Friends here I am introducing a new code for temperature converter. This is a graphical converter that you can use and run with your converter. Hope you like this thanks.   



#include
#include
#include
#include
#include
#include
#include
   //////////////////////
   int xfm1=200,xfm2=230,chf1=0,chf2=0,ex1=0,ex2=0;

  void calshp();

  void main()
  {
  int gdriver = DETECT, gmode;
  initgraph(&gdriver, &gmode, "c:\\tc\\bgi");

 char ch,mv;
 float cel,f,k,temp;
 calshp();

/////////////////////////////////////////////////////////////////////////////
gotoxy(23,10);
cin>>temp;


    do
{   calshp();

if(mv==72)
   {   chf1-=30;
chf2-=30;
}
   if(mv==80)

    {chf1+=30;
     chf2+=30;
    }
    if(chf1>180)
    {
      chf1=0;
      chf2=0;
      }
    if(chf1<0)
    {  chf1=180,chf2=180;}

    if(chf1==180)
    {ex1=70,ex2=80;}
    if(chf1!=180)
    {ex1=0,ex2=0;}

  setcolor(BLUE);
  rectangle(160+ex1,xfm1+chf1,430-ex2,xfm2+chf2);
     mv=getche();
     }
     while(mv!=13);

if(chf1==0)
{
ch=1; }
else if(chf1==30)
{
ch=2;
}
else if(chf1==60)
{
ch=3;
}
else if(chf1==90)
{
ch=4;
}
else if(chf1==120)
{
ch=5;
}
else if(chf1==150)
{
ch=6;
}

////////////////////////////////////////////////////////////////////////////

   switch(ch)
   {

  case 1:
    cel=5*(temp-32)/9;
    gotoxy(23,10);
    cout<
   gotoxy(40,10);
   cout<
    break;

  case 2:
    f=9*(temp+32)/5;
    gotoxy(23,10);
    cout<
    gotoxy(40,10);
    cout<

  break;

  case 3:
    k=temp+273;
    gotoxy(23,10);
    cout<
    gotoxy(40,10);
    cout<
  break;

  case 4:
    cel=273-temp;
    gotoxy(23,10);
    cout<
    gotoxy(40,10);
    cout<
  break;

  case 5:
    cel=5*(temp-32)/9;
    k=cel+273;
    gotoxy(23,10);
    cout<
    gotoxy(40,10);
    cout<


  break;

  case 6:
cel=273-temp;
f=9*(cel+32)/5;
gotoxy(23,10);
    cout<
    gotoxy(40,10);
    cout<
break;

 }



 getche();
 }



void calshp()
{

  setcolor(RED);
  settextstyle(4,0,6);
  outtextxy(90,4,"Temprature Converter");
  rectangle(70,10,580,70);
/////////////////////////////////////////////////////////////////////
  settextstyle(0,0,0);
  rectangle(130,135,460,165);
  rectangle(130,135,290,165);
  outtextxy(180,125,"Input");
  outtextxy(340,125,"Output");
  rectangle(160,xfm1,430,xfm2);
  rectangle(160,xfm1+30,430,xfm2+30);
  rectangle(160,xfm1+60,430,xfm2+60);
  rectangle(160,xfm1+90,430,xfm2+90);
  rectangle(160,xfm1+120,430,xfm2+120);
  rectangle(160,xfm1+150,430,xfm2+150);
  rectangle(230,xfm1+180,350,xfm2+180);
  outtextxy(190,210,"Fahrenheit   To   Celsius");
  outtextxy(190,240,"Celsius   To   Fahrenheit");
  outtextxy(190,270,"Celsius   To   Kalvin");
  outtextxy(190,300,"Kalvin    To   Celsius");
  outtextxy(190,330," Fahrenheit  To  Kalvin");
  outtextxy(190,360," Kalvin  To  Fahrenheit");
  outtextxy(270,390,"Exit");
  setcolor(BLUE);
  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,180,"T      T");
  }


More C++ and C codes:


C and C++ classes

Hope you like theses codes. Thanks





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.

Wednesday, 14 December 2011

How to make a graphical calculator with C++ &C



This is the code for graphical calculator. You can copy this code and past in notepad and then run it with your C & C++ compilers.



;#include
#include                                       
#include
#include
#include
#include
 void shp();
 void main()
  {
  int gdriver = DETECT, gmode;
  initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
  int x1=0,x2=0,y1=0,y2=0;
  float ac,bc,rc;
  char ch;
  shp();
  gotoxy(22,7);
  cout<<"=     ";
  cin>>ac;
//////////////////////////////////////////////////////////////////////////////
do
 {
shp();
 if(ch==72)
   {y1-=20;
    y2-=20;}

 if(ch==80)
   {y1+=20;
    y2+=20;}

 if(ch==75)
   { x1-=100;
     x2-=100;}

 if(ch==77)
    {x1+=100;
     x2+=100;}

 if(x1>300 ||y1>20)
   { x1=0;
     x2=0;
     y1=0;
     y2=0;}

 if(x1<0||y1<0)
   { x1=300;
     x2=300;
     y1=20;
     y2=20;}
/////////////////////////////////////////////////////////////////////////////
   setcolor(BLUE);
   rectangle(150+x1,150+y1,250+x2,170+y2);

   ch=getche();
    }
    while(ch!=13);
//////////////////////////////////////////////////////////////////////////////


  gotoxy(22,9);
  cout<<"=     ";
  cin>>bc;
  clrscr();
  shp();

    if(x1==0)
    {ch=1;}
    if(x1==100)
    {ch=2;}
    if(x1==200)
    {ch=3;}
    if(x1==300)
    {ch=4;}
    if(y1==20&&x1==0)
    {ch=5;}
    if(y1==20&&x1==100)
    {ch=6;}
    if(y1==20&&x1==200)
    {ch=7;}
    if(y1==20&&x1==300)
    {ch=8;}
//////////////////////////////////////////////////////////////////////////////


    switch(ch)
      {
case 1:
 outtextxy(340,105,"sum");
 gotoxy(30,7);
 cout<
 gotoxy(53,7);
 cout<<""<
 gotoxy(30,9);
 cout<
 gotoxy(58,9);
 cout<
break;

case 2:
 outtextxy(340,105,"sub");
 gotoxy(30,7);
 cout<
 gotoxy(53,7);
 cout<<""<
 gotoxy(30,9);
 cout<
 gotoxy(58,9);
 cout<
break;
case 3:
 outtextxy(338,109,"mul");
 gotoxy(30,7);
 cout<
 gotoxy(53,7);
 cout<<""<
 gotoxy(30,9);
 cout<
 gotoxy(58,9);
 cout<
break;
case 4:
 outtextxy(338,109,"div");
 gotoxy(30,7);
 cout<
 gotoxy(53,7);
 cout<<""<
 gotoxy(30,9);
 cout<
 gotoxy(58,9);
 cout<
break;
case 5:
 setcolor(RED);
 settextstyle(4,0,3);
 outtextxy(340,90,"=");
 gotoxy(30,7);
 cout<
 gotoxy(53,7);
 cout<
 gotoxy(30,9);
 cout<
 gotoxy(53,9);
 cout<

break;
case 6:

 setcolor(RED);
 settextstyle(4,0,3);
 outtextxy(340,90,"=");
 gotoxy(30,7);
 cout<
 gotoxy(53,7);
 cout<
 gotoxy(30,9);
 cout<
 gotoxy(53,9);
 cout<

break;
case 7:
 setcolor(RED);
 settextstyle(4,0,3);
 outtextxy(340,90,"=");
 gotoxy(30,7);
 cout<
 gotoxy(53,7);
 cout<
 gotoxy(30,9);
 cout<
 gotoxy(53,9);
 cout<


break;
case 8:
 outtextxy(338,109,"pwr");
 gotoxy(30,7);
 cout<
 gotoxy(53,7);
 cout<<""<
 gotoxy(30,9);
 cout<
 gotoxy(58,9);
 cout<

break;
     }
     getche();
     }
//////////////////////////////////////////////////////////////////////////////

   void shp()
   {

   setcolor(3);
   rectangle(135,10,570,70);
   settextstyle(4,0,6);
   outtextxy(160,4,"Simple Calculator");
////////////////////////////////////////////////////////////////////////////////////////
   setcolor(RED);
   rectangle(145,86,555,275);
   rectangle(153,88,547,120);
   rectangle(150,94,330,145);
   rectangle(150,94,330,120);
   rectangle(150,94,370,145);
   settextstyle(4,0,3);
   outtextxy(340,113,"=");


   setcolor(WHITE);
   rectangle(150,90,550,150);
   rectangle(150,90,550,190);
   rectangle(150,170,550,190);


   rectangle(150,150,250,190);
   rectangle(150,150,350,190);
   rectangle(150,150,450,190);
//////////////////////////////////////////////////////////////////////////////

   settextstyle(4,0,1);
   outtextxy(185,147,"+");
   outtextxy(276,148,"-");
   outtextxy(378,146,"*");
   settextstyle(0,0,0);
   outtextxy(466,160,"/");
   outtextxy(182,175,"cube");
   outtextxy(273,175,"sqr");
   outtextxy(375,175,"sqrt");
   outtextxy(466,175,"power");

/////////////////////////////////////////////////////////////////////////////

   setcolor(RED);
   outtextxy(340,195,"Help");
   setcolor(6);
   outtextxy(165,210,"1 Enter 1st value in block 1.");
   outtextxy(165,225,"2 Enter 2nd value in block 2.");
   outtextxy(165,240,"3 Move curser up and down with arrow keys.");
   outtextxy(165,255,"4 Press ""Enter"" key to select operation.");
   settextstyle(4,0,16);
   outtextxy(30,110,"W       j");
   outtextxy(30,30,"W");

  setcolor(3);
  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");
   setcolor(9);
   circle(350,360,40);
   outtextxy(325,355,"Welcome");

//////////////////////////////////////////////////////////////////////////////////////
   }


Hope you Like this

Saturday, 26 November 2011

Make an invisible folder

Make a folder that will be invisible to everyone and only you will knew its location. The others users my not find this folder and this folder may become a way for you to protect your data from others.
Follow the following steps to make your folder:

1) Make a new folder
2) Rename it and while renaming it hold ctrl key and press 0160 (ctrl+0160) and leave the key
3) Your folder will become nameless now check folder properties and click on change icon
4) Select empty icon and apply it
5) Your folder is ready. You can only open it by going on its position and double clicking


Hope you like this trick.Please bookmark us. Thanks


Friday, 25 November 2011

Make your hard drive invisible



If you have some private data in your hard drive and your computer is used by every other members then you can use this code to make your hard drive invisible from everyone. Use the following code to try this trick:

Follow these steps:
1)  Go To Run
2)  write 'Regedit '
3)   "HKEY_CURRENT_USER
4)   S0ftware 
5)   micros0ft
6)   wind0ws
7)   current vesi0n
8)   p0licies
9)  xpl0rer
10)  current vesi0n
11)  p0licies
12)  xpl0rer
13)  Modify its value and set it to " 3FFFFFF "

At the end restart Your Computer and see what happen.







Hope you like this Please book mark us. Thanks






Wednesday, 23 November 2011

Run commadn list


Following is the list of run commands that you can use in run box and save your time of data browsing from your hard disk.







Work....                             Commands

Command Prompt                 cmd
Add/Remove Programs         appwiz.cpl
Adobe Acrobat                     acrobat
Calculator                              calc
Clipboard Viewer                  clipbrd
Control Panel                        control
Date and Time Properties      timedate.cpl
Device Manager                    devmgmt.msc
Disk Defragment                   dfrg.msc
Disk Partition Manager         diskpart
Display Properties                control desktop
Display Properties                desk.cpl
Event Viewer                        eventvwr.msc
Findfast                                findfast.cpl
Game Controllers                 joy.cpl
Help and Support                helpctr
Internet Explorer                  iexplore
IP Configuration                   ipconfig /all
Logs You Out Of Windows     logoff
Microsoft Paint                     mspaint
Microsoft Powerpoint           powerpnt
Microsoft Word                   winword
Real Player                           realplay
Registry Editor                      regedit32
Remote Desktop                   mstsc
Shuts Down Windows           shutdown
Sounds and Audio                 mmsys.cpl
System Properties                 sysdm.cpl
Task Manager                      taskmgr
User Account Management    nusrmgr.cpl
Windows XP Tour                 tourstart
Wordpad                               write

Sound and Delay Functions in C & C++

Sound functions is used to make a sound or a sequence of sound in program. For example a piano C++ project use different sequences to get different sounds. Let start now:

#include<dos.h>
void main()
{

sound(any number);  //any sound number or name
sound(1200);

Different numbers contain different sounds and always remember that there should be a nosound();
function that end the sound. Use delay function to increase or decrease the timing of the sound.
delay(1000); // 1000=1 second

Review:

#include<dos.h>

void main()
{
clrscr();
sound(250);
delay(9000); // 9 second
nosound();

getche();
}

Hope you like this post. Thanks

Link:Sound in C++

Saturday, 19 November 2011

Classes and objects


In the following program S1 and S2 are 2 objects are class students. Objects are used for operations:


class student //class student
{
private:
int roll;
public:
void setdata(int r) //member function to setdata
{roll=r;}
void showdata(); //member function to display data
{cout<<roll no. is= "<<roll<<endl;} //use printf(""); in C instead of cout<<;
};

void main()\
{
clrscr();

student s1,s2;              //define two objects of class student

s1.setdata(9); //call member function to set data
s2.setdata(10);

s1.showdata(); //call member function to display data
s2.showdata();
getch();
}

C++ Classes

Classes also have same syntax as structures but the difference is that in a class the members are private by default, while in a structure the are public by default.

A Simple Class
Here is the 1st program related to the classes that contain a class and two objects of that class.
Copy this program and run in your compiler and understand it.

#include<iostream.h>    //if you are using C then use <stdio.h>

class student                //class student
{
private:
    int roll;
public:
   void setdata(int r)      //member function to setdata
{roll=r;}
void showdata();         //member function to display data
{cout<<roll no. is= "<<roll<<endl;}     //use printf(""); in C instead of cout<<;
};

void main()\
{
clrscr();

student s1,s2;       //define two objects of class student

s1.setdata(9);      //call member function to set data 
s2.setdata(10);

s1.showdata();   //call member function to display data
s2.showdata();
getch();
}

C and C++ Graphics


Graphics are used in C++ and C programming to make a user friendly software.
Here I will discuss all graphics that I know well. S let's begin

Graphics in C and C++ languages:
Let's start with graphics header file

#include<graphics.h>



Use cleardevice(); instead of clrscr();


void main()
{
cleardevice();

int gd=DETECT,gm; //gd mean graphics detection
//gm mean graphics mode

initgraphics(&gd, &gm,"c:\\tc\\bgi");

/*Above 2 lines are used to get graphics supported files thst may be in c or d derive where you have installed turbo c++ 3.0.
You just have to memorize above 4 lines commands then graphics will become much easy for you.*/

//To draw a circle use following command

circle(x-coordinate,y-coordinate,radius);
for example
circle(250,150,10);

this command will draw circle on 250 and 150 coordinate.
Our computer screen contain 800 columns and 250 rows so adjust according to requirement.

Now to draw rectangle, write

rectangle(x1 coordinate, y1 coordinate, x2 coordinate, y2 coordinate);

for example:
rectangle(120,250,450,100);
similarly
pyramid(120,250,450,100);
and
line(120,250,450,100);
setfillstyle(SOLIDFILL,XFILL); //to fill rectangle r circle with x's

Set color and text styles:

When we use a colour in our program then we use upper case letters for example, RED, BLUE.
We can also colour code for this purpose that's start from 0 and end at 15.

Now to change your background colour write
setbkcolor(RED);
or
setbkcolor(3);

To change text or shapes colours use
setcolor(RED);
or
setcolor(2); //there can be any number instead of 2

To change text style:

settextstyle(horizontal or vertical, style, size);
settextstyle(1,5,8);

and then
outtextxy(x-coordinate,y-coordinate,"any text");
outtextxy(25,100,"My name is waqas");


and at the end
closegraph();

Now let's review the whole commands:

#include<graphics.h>

void main()
{
cleardevice();

int gd=DETECT,gm;
initgraphics(&gd, &gm,"c:\\tc\\bgi");

setbkcolor(ORANGE);
setcolor(RED);

rectangle(25,45,100,150);
line((25,45,100,150);
pyramid((25,45,100,150);

circle(25,100,8);

settextstyle(2,5,10);
outtextxy(100,25,"Welcome");

closegraph();

getch();
}

Link: http://cprogg.blogspot.com/2011/10/c-graphics.html