Wednesday, 17 July 2013

how to use a scrollbar in java

import java.awt.*;
import java.awt.event.*;

class MyFrame extends Frame implements AdjustmentListener
{
 Scrollbar sbr,sbg,sbb;
 Panel p;

 MyFrame()
 {
  setTitle("Scrollbar Demo");
  setSize(400,300);
  setBackground(new Color(200,200,255));

  sbr=new Scrollbar(Scrollbar.VERTICAL,255,10,0,265);
  sbg=new Scrollbar(Scrollbar.VERTICAL,255,10,0,265);
  sbb=new Scrollbar(Scrollbar.VERTICAL,255,10,0,265);

  p=new Panel();
  p.setBackground(Color.black);

  setLayout(new GridLayout(1,2,20,20));
 
  Panel p1=new Panel();
  p1.setLayout(new GridLayout(1,4,15,5));
  p1.add(sbr);
  p1.add(sbg);
  p1.add(sbb);
  p1.add(new Label());

  add(p1);
  add(p);
  
  sbr.addAdjustmentListener(this);
  sbg.addAdjustmentListener(this);
  sbb.addAdjustmentListener(this);

  addWindowListener(new MyWndAdapter(this)); 
 }

 public Insets getInsets()
 {
  return new Insets(50,20,20,20);
 }

 public void adjustmentValueChanged(AdjustmentEvent ae)
 {
  int r,g,b;
  r=255-sbr.getValue();
  g=255-sbg.getValue();
  b=255-sbb.getValue();

  p.setBackground(new Color(r,g,b));
 }
}


class MyWndAdapter extends WindowAdapter
{
 MyFrame mf;

 MyWndAdapter(MyFrame mf)
 {
  this.mf=mf;
 }

 public void windowClosing(WindowEvent we)
 {
  mf.dispose();
  System.exit(0);
 }
}

class SBDemo
{
 public static void main(String arg[])
 {
  MyFrame mf=new MyFrame();
  mf.setVisible(true);
 }
}
---------------------------------------------------------------------------------------------------------------

steps to run the Demo program of Scrollbar
step1: save the file as frm.java file in the bin and refresh it.

step2: after that open ur command prompt and write the path of ur jdk
       
       like my jdk path is
       C:\java\jdk1.7.0_10\bin
step3: if u not know how to make path then follow the steps below





step4: after that to execute the program do the following

C:\java\jdk1.7.0_10\bin>javac SBDemo.java and press enter

step5: if the step4 is successfull then perform this step

C:\java\jdk1.7.0_10\bin>java SBDemo



and enjoy!!  ;)

if u have any problem then msg me at
rawlot007bhati@gmail.com

program for a form window in java

import java.awt.*;
import java.awt.event.*;

class MyFrame extends Frame implements ActionListener
{
 Checkbox cMl,cFl,cCs,cIt,cEc;
 Checkbox cJava,cPython,cRuby,cNet;
 Button bOk,bCancle,bExit;

 CheckboxGroup cbg1,cbg2;

 MyFrame()
 {
  super("FORM");
  setSize(400,350);
  setBackground(new Color(200,200,255));

  Label lSex=new Label("Sex");
  lSex.setFont(new Font("lucida console",Font.PLAIN,18));

  Label lBranch=new Label("Branch");
  lBranch.setFont(new Font("lucida console",Font.PLAIN,18));

  Label lTech=new Label("Technologies");
  lTech.setFont(new Font("lucida console",Font.PLAIN,18));

  cJava=new Checkbox("Java");
  cJava.setFont(new Font("lucida console",Font.PLAIN,18));
  cPython=new Checkbox("Python");
  cPython.setFont(new Font("lucida console",Font.PLAIN,18));
  cRuby=new Checkbox("Ruby");
  cRuby.setFont(new Font("lucida console",Font.PLAIN,18));
  cNet=new Checkbox(".Net");
  cNet.setFont(new Font("lucida console",Font.PLAIN,18));
 
  cbg1=new CheckboxGroup();
  cMl=new Checkbox("Male",cbg1,true);
  cMl.setFont(new Font("lucida console",Font.PLAIN,18));
  cFl=new Checkbox("Female",cbg1,false);
  cFl.setFont(new Font("lucida console",Font.PLAIN,18));

  cbg2=new CheckboxGroup();
  cCs=new Checkbox("CS",cbg2,true);
  cCs.setFont(new Font("lucida console",Font.PLAIN,18));
  cIt=new Checkbox("IT",cbg2,false);
  cIt.setFont(new Font("lucida console",Font.PLAIN,18));
  cEc=new Checkbox("EC",cbg2,false);
  cEc.setFont(new Font("lucida console",Font.PLAIN,18));

  bOk=new Button("OK");
  bOk.setFont(new Font("lucida console",Font.PLAIN,18));
  bOk.setBackground(new Color(200,255,200));
 
  bCancle=new Button("Cancle");
  bCancle.setFont(new Font("lucida console",Font.PLAIN,18));
  bCancle.setBackground(new Color(255,200,200));

  bExit=new Button("Exit");
  bExit.setFont(new Font("lucida console",Font.PLAIN,18));
  bExit.setBackground(new Color(220,220,255));

  Panel p1=new Panel();
  p1.setLayout(new BorderLayout(57,10));

   Panel p11=new Panel();
   p11.setLayout(new GridLayout(1,2,10,10));
   p11.add(cMl);
   p11.add(cFl);

  p1.add(lSex,BorderLayout.WEST);
  p1.add(p11,BorderLayout.CENTER);


  Panel p2=new Panel();
  p2.setLayout(new BorderLayout(30,10));

   Panel p21=new Panel();
   p21.setLayout(new GridLayout(1,3,10,10));
   p21.add(cCs);
   p21.add(cIt);
   p21.add(cEc);

  p2.add(lBranch,BorderLayout.WEST);
  p2.add(p21,BorderLayout.CENTER);

  Panel p3=new Panel();
  p3.setLayout(new BorderLayout(10,10));
  
   Panel p31=new Panel();
   p31.setLayout(new GridLayout(1,4,10,10));
   p31.add(cJava);
   p31.add(cPython);
   p31.add(cRuby);
   p31.add(cNet);
 
  p3.add(lTech,BorderLayout.NORTH);
  p3.add(p31,BorderLayout.CENTER);

  Panel p4=new Panel();
  p4.setLayout(new BorderLayout(10,10));

   Panel p41=new Panel();
   p41.setLayout(new GridLayout(1,3,20,20));
   p41.add(bOk);
   p41.add(bCancle);
   p41.add(bExit);

  p4.add(new Label(),BorderLayout.NORTH);
  p4.add(p41,BorderLayout.CENTER);
  
  setLayout(new GridLayout(4,1,10,10));
  add(p1);
  add(p2);
  add(p3);
  add(p4);

  addWindowListener(new MyWndAdapter(this));

  bOk.addActionListener(this);
  bCancle.addActionListener(this);
  bExit.addActionListener(this);
 
 }

 public Insets getInsets()
 {
  return new Insets(50,20,20,20);
 }

 public void actionPerformed(ActionEvent ae)
 {
  if(ae.getSource()==bOk)
  {
   String str="Sex          : ";
   str=str+cbg1.getSelectedCheckbox().getLabel();
  
   str=str+"\nBranch       : "+cbg2.getSelectedCheckbox().getLabel();

   str=str+"\nTechnologies : ";
   if(cJava.getState())
    str=str+"Java  ";
   if(cPython.getState())
    str=str+"Python  ";
   if(cRuby.getState())
    str=str+"Ruby  ";
   if(cNet.getState())
    str=str+".Net  ";

   System.out.println(str);

  }
  else
  if(ae.getSource()==bCancle)
  {
  
  }
  else
  if(ae.getSource()==bExit)
  {
   dispose();
   System.exit(0);
  }
 }

}


class MyWndAdapter extends WindowAdapter
{
 MyFrame mf;

 MyWndAdapter(MyFrame mf)
 {
  this.mf=mf;
 }

 public void windowClosing(WindowEvent we)
 {
  mf.dispose();
  System.exit(0);
 }
}

class frm
{
 public static void main(String arg[])
 {
  MyFrame mf=new MyFrame();
  mf.setVisible(true);
 }

-------------------------------------------------------------------------------------------------------------
steps to run the Demo program of Form

step1: save the file as frm.java file in the bin and refresh it.

step2: after that open ur command prompt and write the path of ur jdk
       
       like my jdk path is
       C:\java\jdk1.7.0_10\bin
step3: if u not know how to make path then follow the steps below






step4: after that to execute the program do the following

C:\java\jdk1.7.0_10\bin>javac frm.java and press enter



step5: if the step4 is successfull then perform this step

C:\java\jdk1.7.0_10\bin>java frm

then a window appears like this




and enjoy!!  ;)

if u have any problem then msg me at
rawlot007bhati@gmail.com

program to copy paste in java

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

class TextDemo extends Frame implements ActionListener,KeyListener,WindowListener
{
 TextField tSrc,tDst;
 Button bCpy,bMov,bSel,bClr;

 TextDemo()
 {
  setTitle("TextDemo");
  setSize(550,350);
  setBackground(new Color(150,150,150));

  tSrc=new TextField();
  tSrc.setFont(new Font("lucida console",Font.PLAIN,18));
 
  tDst=new TextField();
  tDst.setFont(new Font("lucida console",Font.PLAIN,18));
  tDst.setEditable(false);

  bCpy=new Button("Copy");
  bCpy.setFont(new Font("lucida console",Font.PLAIN,18));
  bCpy.setBackground(new Color(255,190,190));
  bCpy.setEnabled(false);
 
  bMov=new Button("Move");
  bMov.setFont(new Font("lucida console",Font.PLAIN,18));
  bMov.setBackground(new Color(255,190,190));
  bMov.setEnabled(false);

  bSel=new Button("Copy Selected");
  bSel.setFont(new Font("lucida console",Font.PLAIN,18));
  bSel.setBackground(new Color(255,190,190));
  bSel.setEnabled(false);

  bClr=new Button("Clear");
  bClr.setFont(new Font("lucida console",Font.PLAIN,18));
  bClr.setBackground(new Color(190,255,190));

  Label l1=new Label("Source");
  l1.setFont(new Font("lucida console",Font.PLAIN,18));

  Label l2=new Label("Destination");
  l2.setFont(new Font("lucida console",Font.PLAIN,18));

  setLayout(new GridLayout(4,1,10,10));
 
  Panel p1=new Panel();
  p1.setLayout(new BorderLayout(43,10));
 
  p1.add(l1,BorderLayout.WEST);
  p1.add(tSrc,BorderLayout.CENTER);

  Panel p2=new Panel();
  p2.setLayout(new BorderLayout(10,10));
  p2.add(l2,BorderLayout.WEST);
  p2.add(tDst,BorderLayout.CENTER);

  Panel p3=new Panel();
  p3.setLayout(new GridLayout(1,4,5,10));
  p3.add(bCpy);
  p3.add(bMov);
  p3.add(bSel);
  p3.add(bClr);

  add(p1);
  add(p2);
  add(new Label());
  add(p3);
  
  bCpy.addActionListener(this);
  bMov.addActionListener(this);
  bSel.addActionListener(this);
  bClr.addActionListener(this);
  tSrc.addKeyListener(this);
  addWindowListener(new MyWndAdapter(this));
 }

 public Insets getInsets()
 {
  return new Insets(50,20,20,20);
 }



 public void actionPerformed(ActionEvent ae)
 {
  if(ae.getSource()==bClr)
  {
   tSrc.setText("");
   tDst.setText("");
   bCpy.setEnabled(false);
   bMov.setEnabled(false);
   bSel.setEnabled(false);
  }
  else
  if(ae.getSource()==bCpy)
   tDst.setText(tSrc.getText());
  else
  if(ae.getSource()==bMov)
  {
   tDst.setText(tSrc.getText());
   tSrc.setText("");
   bCpy.setEnabled(false);
   bMov.setEnabled(false);
   bSel.setEnabled(false);
  }
  else
  if(ae.getSource()==bSel)
  {
   tDst.setText(tSrc.getSelectedText());
  }
 }

 public void keyTyped(KeyEvent ke){}
 public void keyPressed(KeyEvent ke){}

 public void keyReleased(KeyEvent ke)
 {
  if(tSrc.getText().length()==0)
  {
   bCpy.setEnabled(false);
   bMov.setEnabled(false);
   bSel.setEnabled(false);
  }
  else
  {
   bCpy.setEnabled(true);
   bMov.setEnabled(true);
   bSel.setEnabled(true);
  }
 }

    @Override
    public void windowOpened(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void windowClosing(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void windowClosed(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void windowIconified(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void windowDeiconified(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void windowActivated(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void windowDeactivated(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
class MyWndAdapter extends WindowAdapter
{
  TextDemo td;
  MyWndAdapter(TextDemo td)
 {
  this.td=td;
 }
  public void windowClosing(WindowEvent we)
 {
  td.dispose();
  System.exit(0);
 }
}


class Text
{
public static void main(String arg[])
{
TextDemo td;
td=new TextDemo();
td.setVisible(true);
}
}



----------------------------------------------------------------------------------------------------------
steps to run the Demo program of Text

step1: save the file as textdemo.java file in the bin and refresh it.

step2: after that open ur command prompt and write the path of ur jdk
       
       like my jdk path is
       C:\java\jdk1.7.0_10\bin
step3: if u not know how to make path then follow the steps below











step4: after that to execute the program do the following




if there is no error then proceed to step5 otherwise correct the error

step5:after success of step4 perform the following



after this a window appear like this



enjoy!! ;)
if u have any queries then message me on
rawlot007bhati@gmail.com

Sunday, 6 January 2013

PROGRAM FOR PUSH POP IN C


#include<conio.h>
#include<stdio.h>
int conv(char ch);
void push(int);
void pop(int);
int stack[30],top=-1;
void main()
{
int i,j,n;
char str[30],c;
clrscr();
printf("enter string as postfix:");
scanf("%s",&str);
for(i=0;str[i]!='\0';i++)
{
printf("%c",str[i]);
if(str[i]!=',')
{
c=str[i];
n=conv(c);
if(n<0)
pop(n);
else
{
push(n);
}
}
}
printf("result= %d",stack[0]);
getch();
}
int conv(char ch)
{
int i,num=0;
switch(ch)
{
case '0':num=0;break;
case '1':num=1;break;
case '2':num=2;break;
case '3':num=3;break;
case '4':num=4;break;
case '5':num=5;break;
case '6':num=6;break;
case '7':num=7;break;
case '8':num=8;break;
case '9':num=9;break;
case '+':num=-1;break;
case '-':num=-2;break;
case '*':num=-3;break;
case '/':num=-4;break;
case '%':num=-5;break;
}
return num;
}
void push(int num)
{
stack[++top]=num;
}
void pop(int ch)
{
int op1,op2,res;
op1=stack[top--];
op2=stack[top--];
switch(ch)
{
case -1:res=op2+op1;break;
case -2:res=op2-op1;break;
case -3:res=op2*op1;break;
case -4:res=op2/op1;break;
case -5:res=op2%op1;break;
}
push(res);
}

PROGRAM FOR STRING SORTING IN JAVA


import java.io.*;

class StringSort

{

        public static void main ( String args [] )

        throws IOException

        {

                BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in ) );

                System.out.print ( "\n\n\nEnter no. of strings  :  " );

                int n = Integer.parseInt ( br.readLine () );

                String s[] = new String[n];

                System.out.println ();

                for ( int i=0 ; i<n ; i++ )

                {

                        System.out.print ( "\n\nString " + (i+1) + "  :  " );

                        s[i] = br.readLine();

                }

                for ( int i=0 ; i<n-1 ; i++ )

                {

                        for ( int j=0 ; j<n-1-i ; j++ )

                        {

                                if ( s[j].compareTo ( s[j+1] ) > 0 )

                                {

                                        String tmp = s[j];

                                        s[j] = s[j+1];

                                        s[j+1] = tmp;

                                }

                        }

                }

                System.out.println ( "\n\n\nAfter sorting - \n\n" );

                for ( int i=0 ; i<n ; i++ )

                {

                        System.out.print ( "\nString " + (i+1) + "  :  " );

                        System.out.println ( s[i] + "\n" );

                }

                System.out.println ();

        }

}

PROGRAM FOR CONCATENATE OF STRING IN JAVA


import java.io.*;

class Concate

{

        public static void main ( String args [] )

        throws IOException

        {

                BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in ) );

                System.out.print("\n\nEnter 1st String  :   ");

                String s1 = new String ( br.readLine() );

                System.out.print("\n\nEnter 2nd String  :   ");

                String s2 = new String ( br.readLine() );

                StringBuffer sb = new StringBuffer( concatenate ( s1 , s2 ) );

                System.out.println("\n\nStringBuffer      :   " + sb + "\n" );

        }

        public static String concatenate ( String s1 , String s2 )

        {

                return ( s1 + ' ' + s2 );

        }

}

PROGRAM FOR LEAP YEAR IN JAVA


class A

{

        int yr;

        A ( int yr )

        {

                this.yr = yr;

        }

        int IsLeap ()

        {

                if ( yr%400 == 0 )

                        return (0);

                else if ( yr%4 == 0 )

                        return (1);

                else

                        return (2);

        }
       
}

class Leap

{

        public static void main ( String args[] )

        {

                int y;

                y = Integer.parseInt ( args[0] );

                A a = new A ( y );

                int r = a.IsLeap();

                if ( r==0 )

                        System.out.println("\n\n" + y + " is a Century Leap Year\n");

                else if ( r==1 )

                        System.out.println("\n\n" + y + " is a Leap Year\n");

                else

                        System.out.println("\n\n" + y + " is not a Leap Year\n");

        }

}

PROGRAM FOR PRIME NUMBER IN JAVA


class A

{

        int IsPrime ( int n )

        {

                for ( int i=2 ; i<=n/2 ; i++ )

                {

                        if ( n%i == 0 )

                                return (1);

                }

                return (0);

        }

}

class Prime

{

        public static void main ( String args[] )

        {

                int m = Integer.parseInt ( args[0] );

                A a = new A();

                int r = a.IsPrime ( m );

                if ( r==0 )

                        System.out.println("\n\n" + m + " is a Prime no.\n");

                else

                        System.out.println("\n\n" + m + " is not a Prime no.\n");

        }

}

PROGRAM TO DISPALY DIGITAL CLOCK IN C


#include<graphics.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void refresh(int x, int y)
{
setfillstyle(SOLID_FILL,BLACK);
bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
}

void LCD(int x, int y, int n)
{
refresh(x,y);
setfillstyle(SOLID_FILL,10);
switch(n)
{
case 0: bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
case 1: bar(39+x,7+y,44+x,57+y);       //c
bar(39+x,66+y,44+x,116+y);     //f
break;
case 2: bar(7+x,0+y,37+x,5+y);         //a
//bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
bar(0+x,66+y,5+x,116+y);       //e
//bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
case 3: bar(7+x,0+y,37+x,5+y);         //a
//bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
//bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
case 4: //bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
//bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
//bar(7+x,118+y,37+x,123+y);     //g
break;
case 5: bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
//bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
//bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
case 6: bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
//bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
case 7: bar(7+x,0+y,37+x,5+y);         //a
//bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
//bar(7+x,59+y,37+x,64+y);       //d
//bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
//bar(7+x,118+y,37+x,123+y);     //g
break;
case 8: bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
case 9: bar(7+x,0+y,37+x,5+y);         //a
bar(0+x,7+y,5+x,57+y);         //b
bar(39+x,7+y,44+x,57+y);       //c
bar(7+x,59+y,37+x,64+y);       //d
//bar(0+x,66+y,5+x,116+y);       //e
bar(39+x,66+y,44+x,116+y);     //f
bar(7+x,118+y,37+x,123+y);     //g
break;
}
}
void blink(int color)
{
setcolor(color);
setfillstyle(SOLID_FILL, color);
circle(320,280,4);
circle(320,320,4);
floodfill(320,280,color);
floodfill(320,320,color);

}
void clock(int t1, int t2, int t3, int t4)
{
int i=0;
while(1)
{
if(i==60)
{
  i=0;
  t4++;
}
LCD(200,240,t1);
LCD(250,240,t2);
LCD(350,240,t3);
LCD(400,240,t4);
blink(BLACK);
delay(700);
blink(10);
delay(200);
i++;
if(t1>=2 && t2>=3 && t3>=5 && t4>=9)
  t1=t2=t3=t4=0;
if(t4==10)
{
  t4=0;
  t3++;
  if(t3==5)
  {
    t3=0;
    if(t1!=2 && t2!=3)
    {
      t2++;
      if(t2 == 10)
      {
t2=0;
t1++;
      }
    }
  }
}
}
}
void main()
{
int gm, gd = DETECT,time,t1,t2,t3,t4;
initgraph(&gd, &gm, "..//bgi");
cleardevice();
printf("Enter Time: ");
scanf("%d",&time);
t4=time%10;
time/=10;
t3=time%10;
time/=10;
t2=time%10;
t1=time/10;
//printf("%d\t%d\t%d\t%d",t1,t2,t3,t4);
clock(t1,t2,t3,t4);
getch();
closegraph();
}

TUTORIAL FOR SQL(VIDEO)