Friday, 7 August 2015

How to make a div scroll-able?



To make div horizontally scroll-able add overflow-x:scroll style to div as:


<div style="overflow-x: scroll; width: 300px;">
In HTML, span and div elements are used to define parts of a document so that they are identifiable when no other HTML element is suitable.
<div>




To make div vertically scroll-able add overflow-y:scroll style to div as:


<div style="overflow-y: scroll; height: 300px;">
In HTML, 
span and div elements are used 
to define parts of a document 
so that they are identifiable 
when no other HTML element is suitable. 
<div>


To make div  scroll-able both horizontally & vertically then  add overflow:scroll style to div as:


<div style="overflow: scroll; height: 300px; width:400px;">
In HTML, 
span and div elements are used 
to define parts of a document 
so that they are identifiable 
when no other HTML element is suitable. 
<div>

Thursday, 6 August 2015

Add Lyrics to mp3 file using Windows Media Player in simple steps



Download the Lyrics Plugin for Windows Media Player from www.lyricsplugin.com

Install it and play any song.

Click [Search Google] to find the lyrics of that song. Copy the lyrics.

Click [Edit] and paste the copied lyrics in lyrics textbox, you can also change the Title and Artist.
Click Save Changes

Now whenever you open that song you can see the lyrics of that song

Tuesday, 4 August 2015

Applet Demo 1



Source Code:


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


public class Demo1 extends Applet
{
    public void init()
    {
        //Code to run automatically
        this.setSize(500, 500);
        this.setBackground(Color.CYAN);
    }
    public void paint(Graphics g)
    {
        
        
        //now draw graphics
        g.drawLine(0, 0, 100, 100);
        g.drawRect(0, 0, 100, 100);
        
        //change color of graphics
        g.setColor(Color.blue);
        g.drawString("Applet Demo", 0, 120);
    }
}

Monday, 3 August 2015

Getting Started with Java GUI Programming



Download the Netbeans IDE from filehippo.com/download_netbeans

Also download Java JDK(32-bit or 64-bit) according to your operating system. For 32-bit operating system download the 32-bit version of Java JDK and for 64-bit operating system download the 64-bit version of Java JDK

After downloading firstly install Java JDK and then Netbeans

Sunday, 2 August 2015

Binary Search Program



#include<iostream.h>
#include<conio.h>
void main()
{ 
 clrscr();
int n,*a,item,loc=-1;
cout<<"\nenter the no. of elements :";
cin>>n;
a=new int[n];  //dynamically initialize array
cout<<"\nenter the elements:\n";
for(int i=0;i<n;i++)
cin>>a[i];
cout<<"\nenter the element you want to search: ";
cin>>item;
int mid,end=n,beg=0;
while(beg<=end&&loc==-1)
{
 mid=(beg+end)/2;
 if(a[mid]==item)
  loc=mid; 
 else if(a[mid]<item)
  beg=mid+1;
 else
  end=mid-1;
}
if(loc!=-1)
      cout<<"\nlocation of "<<item<<" is:"<<loc+1;
else
      cout<<"\n"<<item<<" not found!!!";
getch();
}

Linear Search Program



#include<iostream.h>
#include<conio.h>
void main()
{     clrscr();
int  *a,n,loc=-1,item;
cout<<"\nenter the no. of elements (max. 10):";
cin>>n;
a=new int[n];  //dynamically initialize array
cout<<"\nenter the elements:\n";
for(int i=0;i<n;i++)
cin>>a[i];
cout<<"\nenter the element to be searched: ";
cin>>item;
for(i=0;i<n;i++)
      if(a[i]==item)
      {      loc=i;
             break;    
      }
if(loc==-1)
     cout<<"\n"<<item<<" not found!!!";
else
     cout<<"location of "<<item<<" is: "<<loc+1;
getch();
}

Selection Sort Program



#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,temp,min;
cout<<"\nEnter the no. of elements you want:";
cin>>n;
int *a=new int[n];  //dynamically initialize array
cout<<"\nEnter the elements:\n";
for(int i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
{
 min=i;
 for(int j=i+1;j<n;j++)
 {
  If(a[min]>a[j])
   min=j;
 }
 temp=a[min];
 a[min]=a[i];
 a[i]=temp;
}
cout<<"\nSorted list of given integers is(in ascending order) :\n";
for(i=0;i<n;i++)
cout<<a[i]<<" ";
getch();
}



Bubble Sort Program


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,temp;
cout<<"\nEnter the no. of elements you want:";
cin>>n;
int *a=new int[n];  //dynamically initialize array
cout<<"\nEnter the elements:\n";
for(int i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
{
 for(int j=0;j<n-i-1;j++)
 {
  if(a[j]>a[j+1])
  {
   temp=a[j];
   a[j]=a[j+1];
   a[j+1]=temp;
  }
 }
}
cout<<"\nSorted list of given integers is(in ascending order) :\n";
for(i=0;i<n;i++)
cout<<a[i]<<" ";
getch();
}



Merge Sort Program


#include<iostream.h>
#include<conio.h>
#include<values.h>
void merge(int a[],int p,int q,int r)
{
 int n1=q-p+1,n2=r-q;
 int *l=new int[n1+1];
 int *rt=new int[n2+1];
 for(int i=0;i<n1;i++)
       l[i]=a[p+i];

 for(int j=0;j<n2;j++)
  rt[j]=a[q+j+1];  
 l[n1]=MAXINT;   //SENTINEL
 rt[n2]=MAXINT;  //SENTINEL
 i=j=0;
 for(int k=p;k<=r;k++)
 {
  if(l[i]<=rt[j])
  {
   a[k]=l[i];
   i+=1;
  }
  else
  {
   a[k]=rt[j];
   j+=1;
  }
 }
}
void mergesort(int a[],int p,int r)
{
 int q;
 if(p<r)
 {
  q=(p+r)/2;
  mergesort(a,p,q);
  mergesort(a,q+1,r);
  merge(a,p,q,r);
 }
}
void main()
{
 clrscr();
 int n;
 cout<<"\nEnter the no. of elements you want:";
 cin>>n;
 int *a=new int[n];  //dynamically initialize array
 cout<<"\nEnter the elements:\n";
 for(int i=0;i<n;i++)
  cin>>a[i];

 mergesort(a,0,n-1);
 cout<<"\n\nSORTED ARRAY IS:\n";
 for( i=0;i<n;i++)
  cout<<a[i]<<" ";
 getch();
}