Wednesday 26 October 2011

Industrial Tour Letter


http://www.mediafire.com/?cft0sdcxytuf3lc



Download Industrial Letter  And Submit it To Mahesh or Pranathi

Monday 24 October 2011

Program on Hashing Chain



#include<iostream>
#include<cstdlib>
using namespace std;
class hashch
{
      struct node
      {
             int value;
             node *link;
      };
     public:
            struct node *hashtable[10];
            void insert(int);
            void del(int);
            bool search(int);
            void display();
            void inp();

};
void hashch::inp()
{
 for(int i=0;i<10;i++)
     {
                      hashtable[i]=NULL;
     }
}
void hashch::insert(int val)
{
     int c,i;

     node *t;
     t=new node;
     t->value=val;
     t->link=NULL;
     c=val%10;
     if(hashtable[c]==NULL)
           hashtable[c]=t;
     else
     {
         node*p;
         p=new node;
         p=hashtable[c];
         if(val<p->value)
         {
                       t->link=p;
                       hashtable[c]=t;
         }
         else
         {
             while (val>p->link->value&&p->link!=NULL)
             p=p->link;
             if(p->link->link!=NULL)
            {
                t->link=p->link;
                p->link=t;
             }
             else if(val<p->link->value)
             {
                  t->link=p->link;
                  p->link=t;
             }
             else
             p->link->link=t;
         }
     }
}
void hashch::del(int val)
{
     int c;
     node *t,*p ;
     c=val%10;
     t=new node;
     p=new node;

     if(hashtable[c]!=NULL)
     {
                          if(t->value==val)
                          {
                            t=hashtable[c];
                            hashtable[c]=hashtable[c]->link;
                           delete t;
                          }
                          else
                          {
                                  p=hashtable[c];
                                  while(p->link->link!=NULL&&p->link->value!=val)
                                  {
                                       p=p->link;

                                  }
                                  if(t->link->link!=NULL)
                                  {
                                                          t=p->link;
                                                          p->link=p->link->link;
                                                          free(t);
                                  }
                                   else
                                   t->link=NULL;
                          }
}
                          else
                          cout<<"\nThe bucket doesnt exist\n";
}

bool hashch::search(int val)
{
     int c;
     node *t;
     c=val%10;
     t=hashtable[c];
     if(hashtable[c]!=NULL)
     {
                           while(t!=NULL)
                           {
                                         if(t->value==val)
                                         {
                                                          cout<<"Found\n";
                                                          return true;
                                         }
                                         else
                                         {
                                             t=t->link;
                                         }
                           }


                               cout<<"The value doesnt exist\n";
                                return false;

     }
     else
     cout<<"The bucket is empty\n";
}
void hashch::display()
{
    node *p[10];
   node *t;

     int i;
    for(i=0;i<10;i++)
{
     p[i]=hashtable[i];
}
    for(i=0;i<10;i++)
    {
             t=new node;
                     if(p[i]!=NULL)
                     {
                                   t=p[i];
                                    while(t!=NULL)
                                   {

                                   cout<<t->value<<"\t";
                                    t=t->link;
                                    }
                     cout<<"\n";
                     }
                     else
                     cout<<"NULL\n";
      }
}
int main()
{
    hashch ch;
    int option;
    int ele;

    bool ans;
    ch.inp();
    while(1)
    {
            cout<<"\nEnter your choice\n";
            cout<<"\n1.Insert\n2.Delete\n3.Search\n4.Display\n5.Exit\n";
            cin>>option;
            switch(option)
            {
                          case 1:cout<<"\nEnter what you want to insert\n";
                          cin>>ele;
                          ch.insert(ele);
                               break;
                          case 2:cout<<"\nEnter what you want to delete\n";
                               cin>>ele;
                               ch.del(ele);
                                break;
                          case 3:cout<<"\nEnter what you want to search\n";
                                 cin>>ele;
                                 ans=ch.search(ele);
                                 if(ans)
                                  cout<<"\nFound\n";
                                 else
                                  cout<<"\nMissing\n";
                                 break;
                          case 4: ch.display();
                                  break ;
                          case 5: exit(1);
            }
    }
    return 0;

}




OUTPUT:-

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
1

Enter what you want to insert
2

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
3

Enter what you want to search
2
Found

Found

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
1

Enter what you want to insert
4

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
4
NULL
NULL
2
NULL
4
NULL
NULL
NULL
NULL
NULL

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
1

Enter what you want to insert
6

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
4
NULL
NULL
2
NULL
4
NULL
6
NULL
NULL
NULL

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit

Program on add and multiplication of Polynomials


#include<iostream>
using namespace std;
#define n 100
class poly
{
 private:
                int a[n], b[n], add[n], mul[n], p, q, at;
        public:
                void init ( );
void input ( );
                void process ( );
                void display ( );
};
void poly :: init ( )
{
        int i;
        for( i = 0; i < n; i++)
                a[ i ] = b [ i ] = add[ i ] = mul[ i ] = 0;
}
void poly :: input ( )
{
        int i;
    cout<<"\nEnter Degree Of First Polynomial::";
        cin>>p;
        cout<<"\nEnter Degree Of Second Polynomial::";
        cin>>q;
        cout<<"\nEnter Values in First Polynomial\n";
        for( i = 0; i <= p; i++)
        {
                cout<<"\nEnter X^"<<i<<" The Coefficient";
                cin>>a[ i ];
        }
        cout<<"\nEnter Values in Second Polynomial\n";
        for( i = 0; i <= q; i++)
        {
                cout<<"\nEnter X^"<<i<<" The Coefficient";
                cin>>b[ i ];
        }
}
void poly :: process ( )
{
        int i, j;
        if( p > q )
                at = p;
        else
                at = q;
        for ( i = 0; i <= at;i++   )
                add[ i ] = a[ i ] + b[ i ];
                for( i = 0;  i <= p;  i++)
                        for( j = 0; j <= q; j++)
                                  mul[i+j]+= a[i]*b[j];
}
void poly :: display ( )
{
 int i;
cout<<"Addition Of Two Polynomial Expressions Are\n\n";
for( i = at; i >=0 ; i--)
cout<<add[i]<<"X^"<<i<<"+";
cout<<"\n\nMultiplication Of Two Polynomial Expressions Are\n\n";
for( i = p + q; i >= 0; i--)
cout<<mul[i]<<"X^"<< i <<"+";
}
int main()
{
poly ob;
ob.init ( );
ob.input ( );
ob.process ( );
ob.display ( );
return 0;
}


OUTPUT:-

Enter Degree Of First Polynomial::2

Enter Degree Of Second Polynomial::2

Enter Values in First Polynomial

Enter X^0 The Coefficient1

Enter X^1 The Coefficient2

Enter X^2 The Coefficient5

Enter Values in Second Polynomial

Enter X^0 The Coefficient6

Enter X^1 The Coefficient4

Enter X^2 The Coefficient7
Addition Of Two Polynomial Expressions Are

12X^2+6X^1+7X^0+

Multiplication Of Two Polynomial Expressions Are

35X^4+34X^3+45X^2+16X^1+6X^0+

Program on Graph Traversal


#include<iostream>
using namespace std;
class graphtraversal
{
        public:
                int size;
                int **adj;
                void readadj();
                void dfs();
                void bfs();
};
void graphtraversal::readadj()
{
        cout<<"enter no of vertices\n";
        cin>>size;
        adj=new int *[size];
        for(int i=0;i<size;i++)
                adj[i]=new int [size];
        cout<<"enter adj matrix:\n";
        for(int i=0;i<size;i++)
                for(int j=0;j<size;j++)
                        cin>>adj[i][j];
}
void graphtraversal::dfs()
{
        int stack[size],top=-1;
        int start,visited[size];
        for(int i=0;i<size;i++)
                visited[i]=0;
        cout<<"enter starting node:\n";
        cin>>start;
        stack[++top]=start;
        visited[start]=1;
        while(top!=-1)
        {
                start=stack[top--];
                cout<<start<<"  ";
                for(int i=0;i<size;i++)
                {
                        if(adj[start][i]==1 && visited[i]!=1)
                        {
                                stack[++top]=i;
                                visited[i]=1;
                        }
                }
        }
}
void graphtraversal::bfs()
{
        int queue[size],f=-1,r=0;
        int strt,visited[size];
        for(int i=0;i<size;i++)
                visited[i]=0;
        cout<<"enter starting node\n";
        cin>>strt;
        queue[r++]=strt;
        visited[strt]=1;
        while(f!=r-1)
        {
                strt=queue[++f];
                cout<<strt<<" ";
                for(int i=0;i<size;i++)
                {
                        if(adj[strt][i]==1 && visited[i]!=1)
                        {
                                queue[r++]=i;
                                visited[i]=1;
                        }
                }
        }
}
int main()
{
        graphtraversal ob;
        int op,n=1;
        while(n==1)
        {
                cout<<"\nenter the option\n";
                cout<<"1.read adj\n2.DFS\n3.BFS\n4.exit\n";
                cin>>op;
                switch(op)
                {
                        case 1:
                                ob.readadj();
                                break;
                        case 2:
                                ob.dfs();
                                break;
                        case 3:
                                ob.bfs();
                                break;
                        case 4:
                                n=0;
                                break;
                }
        }
}


OUTPUT:-

enter the option
1.read adj
2.DFS
3.BFS
4.exit
1
enter no of vertices
4
enter adj matrix:
0
^Z
[4]+  Stopped                 ./a.out
[b520@localhost ~]$ ./a.out

enter the option
1.read adj
2.DFS
3.BFS
4.exit
1
enter no of vertices
4
enter adj matrix:
0 0 1 0
1 0 0 0
0 0 0 1
0 1 0 0

enter the option
1.read adj
2.DFS
3.BFS
4.exit
2
enter starting node:
0
0  2  3  1
enter the option
1.read adj
2.DFS
3.BFS
4.exit
3
enter starting node
0
0 2 3 1
enter the option
1.read adj
2.DFS
3.BFS
4.exit
4



Program on Hashing


#include<iostream>
#include<cstdlib>
using namespace std;
class ihash
{
      int *p;
      int d;
      public:
             ihash()
             {
                    d=10;
                    }
                    void insert(int);
                    bool search(int);
                    void del(int);
                    void display();
                    void inp();
};
void ihash::inp()
{
     p=new int[10];
     for(int i=0;i<10;i++)
       p[i]=-1;
}

void ihash::insert(int key)
{

     int i;
     i=key%d;
     if(p[i]==-1)
       p[i]=key;
       else
       {
           int j=i;
            i=(i+1)%d;
            while(i!=j)
            {
                       if(p[i]==-1)
                       {
                           p[i]=key;
                           break;
                           }
                        else
                        i=(i+1)%d;
            }
}
}
bool ihash::search(int key)
{
     int i,j;
     i=key%d;
     if(p[i]==key)
       return true;
     else
     {
         j=i;
         i=(i+1)%d;
         while(i!=j)
         {
                    if(p[i]==key)
                    return key;
                    else
                    i=(i+1)%d;
         }
         return false;
     }
}
void ihash::del(int key)
{
     int i,j;
     i=key%d;
     if(p[i]==key)
       p[i]=-1;
     else
     {
         j=i;
         i=(i+1)%d;
         while(i!=j)
         {
                    if(p[i]==key)
                      p[i]=-1;
                    else
                     i=(i+1)%d;
         }
     }

}
void ihash::display()
{
     for(int i=0;i<10;i++)
     {
             if(p[i]==-1)
             cout<<"NULL\n";
             else
             cout<<p[i]<<"\n";
             }
             }
int main()
{
    int option;
    bool ans;
    int key;
    ihash ih;
      ih.inp();

    while(1)
    {


            cout<<"\nEnter your choice\n";
            cout<<"\n1.Insert\n2.Delete\n3.Search\n4.Display\n5.Exit\n";
            cin>>option;
            switch(option)
            {
                          case 1:cout<<"\nEnter the value your want to insert\n";
                                 cin>>key;
                                 ih.insert(key);
                                 break;
                          case 2:cout<<"\nEnter the value you want to delete\n";
                                 cin>>key;
                                 ih.del(key);
                                 break;
                          case 3:cout<<"\nEnter the value you want to search\n";
                                 cin>>key;
                                 ans=ih.search(key);
                                 if(ans)
                                  cout<<"\nFound\n";
                                  else
                                  cout<<"\nMissing\n";
                                 break;
                          case 4:ih.display();
                                  break;
                          case 5:exit(1);
            }
    }
return 0;
}


OUTPUT:-

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
1

Enter the value your want to insert
2

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
1

Enter the value your want to insert
4

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
1

Enter the value your want to insert
6

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
4
NULL
NULL
2
NULL
4
NULL
6
NULL
NULL
NULL

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
3

Enter the value you want to search
4

Found

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
2

Enter the value you want to delete
6

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
4
NULL
NULL
2
NULL
4
NULL
NULL
NULL
NULL
NULL

Enter your choice

1.Insert
2.Delete
3.Search
4.Display
5.Exit
5

Sunday 23 October 2011

Program for Quick Sort


#include<iostream>
#include<cstdlib>
using namespace std;
class sort
{
        int a[20],b[20];
        int low,high;
        public:
                int n;
                int get();
                void getdata();
                void quicksort(int,int);
                void display();

};
void sort::getdata()
{
        cout<<"enter the number of elements in the array";
        cin>>n;
        cout<<"enter the elements";
        for(int i=0;i<n;i++)
                cin>>b[i];
}
int sort::get()
{
   return n;
}
void sort::quicksort(int low,int high)
{
    int p,i,j,t;
    p=i=low,j=high;
    if(i<j)
    {
       while(i<j)
       {
          while(b[p]<b[j])
            j--;
            if(b[p]>b[j])
              {
                 t=b[p];
                 b[p]=b[j];
                 b[j]=t;
                 p=j;
              }
                while(b[p]>b[i])
                    i++;
                   if(b[p]<b[i])
                   {
                        t=b[i];
                        b[i]=b[p];
                        b[p]=t;
                        p=i;
                   }
                        if(i>=j)
                         {
                             quicksort(low,i-1);
                             quicksort(i+1,high);
                         }
        }
     }
}
void sort::display()
{
        cout<<"the sorted list is\n";
        for(int i=0;i<n;i++)
                                               {
                cout<<b[i]<<"\t";
        }
}
int main()
{
        sort a;
        int op;
        while(1)
        {
                cout<<"enter the option\n";
                cout<<"1.get data\n2.quick sort\n3.display\n4.exit\n";
                cin>>op;
                switch(op)
                {
                        case 1:
                                a.getdata();
                                break;
                        case 2:
                                a.get();
                                a.quicksort(0,a.n-1);
                                break;
                        case 3:
                                a.display();
                                break;
                        case 4:
                                exit(1);
                }
        }
}


OUTPUT:-

enter the option
1.get data
2.quick sort
3.display
4.exit
1
enter the number of elements in the array5
enter the elements2
1
3
6
7
enter the option
1.get data
2.quick sort
3.display
4.exit
3
the sorted list is
2       1       3       6       7       enter the option
1.get data
2.quick sort
3.display
4.exit
2
enter the option
1.get data
2.quick sort
3.display
4.exit
3
the sorted list is
1       2       3       6       7       enter the option
1.get data
2.quick sort
3.display
4.exit
4


Program for Linear search and Binary search


#include<iostream>
#include<cstdlib>
using namespace std;
class search
{
        int arr[10];
        public:
        bool linearsearch(int);
        bool binarysearch(int);
        void sort();
        void readarray();
};
bool search::linearsearch(int ele)
{
        for(int i=0;i<10;i++)
                if(arr[i]==ele)
                        return true;
        return false;
}
bool search::binarysearch(int ele)
{
        int low=0,high=9,mid;
        search ob;
        ob.sort();
        while(low<=high)
        {
                mid=(low+high)/2;
                if(ele==arr[mid])
                        return true;
                else if(ele<arr[mid])
                        high=mid-1;
                else
                        low=mid+1;
        }
        return false;
}
void search::sort()
{
        for(int i=0;i<9;i++)
                for(int j=0;j<9;j++)
                        if(arr[j]>arr[j+1])
                        {
                                int temp=arr[j];
                                arr[j]=arr[j+1];
                                arr[j+1]=temp;
                        }
}
void search::readarray()
{
        cout<<"Enter the elements of the array:";
        for(int i=0;i<10;i++)
                cin>>arr[i];
}
int main()
{
        search ob;
        int ele,choice;
        bool b;
        ob.readarray();
        cout<<"Enter the element to be found:";
        cin>>ele;
        cout<<"Which search would you like to use?\n\n1.Linear Search\n2.Binary search\n";
        cin>>choice;
        switch(choice)
        {
                case 1:
                        {
                        b=ob.linearsearch(ele);
                        if(b==true)
                                cout<<"Element found.";
                        else
                                cout<<"Element not found.";
                        }
                break;
                case 2:
                        {
                        b=ob.binarysearch(ele);
                        if(b==true)
                                cout<<"Element found.";
                        else
                                cout<<"Element not found.";
                        }
                break;
        }
}


OUTPUT:-


Enter the elements of the array:2
1
4
6
2
3
1
4
5
6
Enter the element to be found:5
Which search would you like to use?

1.Linear Search
2.Binary search
1
Element found.

B5 Tour Plan


SPECIALLY DESIGNED TOUR PROGRAME FOR
GITAM ENGINEERING COLLEGE STUDENTS
CSE –BRANCH-B5 
AGRA-MATHURA-DELHI-SHIMLA-KUFRI-KULLU-MANALI-CHANDIGARAH-DELHI
DAY-1 Nov22nd –Arrival Delhi at 6: PM, Pick up from station, Transfer to Hotel,
                            Night halt at Delhi. (HOTEL ASHOKA INTERNATIONAL)
DAY-2 Nov23rd -in Breakfast, Dep for Agra
     Visiting AKSHARDHAM TEMPLE
                       COSMO  INFORMATICS PVT LTD    visit Tajmahal, Agra fort
                        Evening Visiting Mathura
 Visiting industry TRANSOFT INFOTECH Night halt at Agra
DAY-2 Nov24th Breakfast, Visiting Indistry HCL
Half day Sight seeing at Delhi
                        Lotus Temple, Birla mandir, India Gate, qutubminar,                                                     Rajghat, and many more places
Dinner   VISITING INDUSTRY  NEWGEN SOFTWARE TECHNOLOGIES LTD
Night halt at Delhi 
DAY-3 Nov25th –Breakfast Half day sight seeing, 
                        Afternoon Dep for Chandigarah
                        Arrival Chandigarah at Evening, Hotel Check-in, Dinner,
Night Halt  
DAY-4Nov26th Breakfast Hotel Check-out
                        Visiting Industry  PARAMOUNT GRAPHICS PVT LTD
Half day sight seeing at Chandigarh.
Visiting Industry SPIC MICROSOFT PVT LTD
Rock Garden, Rose Garden
Night Dep for Manali
 DAY-5 Nov27th Hotel Check-in, Breakfast at Visit Rohtang pass
 (Snow point) Visiting Hadimba temple, solang valley, vashisth Kund (Hot springs)
Night Halt at Manali ( HOTEL APPLE GREEN MANALI)
DAY-6 Nov28th Breakfast, Visiting Water rafting, Kullu temple,
                        Dinner, Night halt
DAY-7 Nov29th Hotel Check-out , Dep for Shimla , Pass through Beas river , sutlez link project, Arrival shimla at evening , Hotel Checkin , Dinner
                        Night halt at shimla (HOTEL SATYAM PARADISE)
DAY-8 Nov30th, Breakfast Hotel check-out
Sight seeing at Shimla VISITING INDUSTRY  (STPI(Software Technology  Parks of India)

                        Visit Kufri – Winter sports Capital, Indira Bungalow and
Other places of tourist importance.
Evening Dep for Delhi at 4:00 PM
                       

DAY-10Dec1st  Dropping at railway Station at 6:00 AM 

Saturday 22 October 2011

Program on Merge Sort


#include<iostream>
#include<cstdlib>
using namespace std;
class array
{
      int a[10],n,b[10];
      public:
             void create(int n);
             void display(int n);
             void sort(int low,int high);
             void mergesort(int low,int mid,int high);

};
void array::create(int n)
{

     cout<<"the elements are:\n";
     for(int i=0;i<n;i++)
     cin>>a[i];
}
void array::display(int n)
{
     for(int i=0;i<n;i++)
     cout<<a[i]<<endl;
}
void array::sort(int low,int high)
{
     if(low<high)
     {
        int mid=(low+high)/2;
        sort(low,mid);
        sort(mid+1,high);
        mergesort(low,mid,high);
     }
}
void array::mergesort(int low,int mid,int high)
{
     int h=low,k=0;
     int i=low;
     int j=mid+1;
     while(h<=mid&&j<=high)
     {
         if(a[h]<a[j])
                b[k++]=a[h++];
         else
                b[k++]=a[j++];
     }
     while(h<=mid)
     {
         b[k++]=a[h++];

     }
       while(j<=high)
            b[k++]=a[j++];
            j=0;
        for(int k=low;k<=high;k++)
        a[k]=b[j++];
}
int main()
{
    array a;
    int n;
    cout<<"the no.of elements in array are:\n";
    cin>>n;
    a.create(n);
    cout<<"the given array is:\n";
    a.display(n);
    int low=0;
    int high=n-1;
    a.sort(low,high);
    cout<<"the sorted array is:\n";
    a.display(n);
    return 0;
}


OUTPUT:-

the no.of elements in array are:
5
the elements are:
1
6
8
2
3
the given array is:
1
6
8
2
3
the sorted array is:
1
2
3
6
8

Program on Selection Sort


#include<iostream>
#include<cstdlib>
using namespace std;
class sort
{
        int a[20];
        int n,t;
        public:
                void getdata();
                void selectionsort();
                void display();
};
void sort::getdata()
{
        cout<<"enter the number of elements in the array\n";
        cin>>n;
        cout<<"enter the elements\n";
        for(t=0;t<n;t++)
                cin>>a[t];
}
void sort::selectionsort()
{
        int small;
        for(int i=0;i<n-1;i++)
        {
                small=i;
                for(int j=i+1;j<n;j++)
                {
                        if(a[small]>a[j])
                        small=j;
                }
                int temp=a[i];
                a[i]=a[small];
                a[small]=temp;
        }
}
void sort::display()
{
        cout<<"the sorted list is\n";
        for(int i=0;i<n;i++)
        {
                cout<<a[i]<<"\t";
        }
}
int main()
{
        sort ob;
        int op;
        while(1)
        {
                cout<<"\nenter the option\n";
                cout<<"1.get data\n2.selection sort\n3.display\n4.exit\n";
                cin>>op;
                switch(op)
                {
                        case 1:
                                ob.getdata();
                                break;
                        case 2:
                                ob.selectionsort();
                                break;
                        case 3:
                                ob.display();
                                break;
                        case 4:
                                exit(1);
                }
        }
}



OUTPUT:-

enter the option
1.get data
2.selection sort
3.display
4.exit
1
enter the number of elements in the array
5
enter the elements
1
6
5
2
3

enter the option
1.get data
2.selection sort
3.display
4.exit
2

enter the option
1.get data
2.selection sort
3.display
4.exit
3
the sorted list is
1       2       3       5       6
enter the option
1.get data
2.selection sort
3.display
4.exit
4

Program on Bubble Sort


#include<iostream>
#include<cstdlib>
using namespace std;
class sort
{
        int a[20];
        int n,t;
        public:
                void getdata();
                void bubblesort();
                void display();
};
void sort::getdata()
{
        cout<<"enter the number of elements in the array\n";
        cin>>n;
        cout<<"enter the elements\n";
        for(t=0;t<n;t++)
                cin>>a[t];
}
void sort::bubblesort()
{
        for(int i=0;i<n-1;i++)
        {
                for(int j=0;j<n-1-i;j++)
                {
                        if(a[j]>a[j+1])
                        {
                                int temp=a[j];
                                a[j]=a[j+1];
                                a[j+1]=temp;
                        }
                }
        }
}
void sort::display()
{
        cout<<"the sorted list is\n";
        for(int i=0;i<n;i++)
        {
                cout<<a[i]<<"\t";
        }
}
int main()
{
        sort ob;
        int op;
        while(1)
        {
                cout<<"\nenter the option\n";
                cout<<"1.get data\n2.bubble sort\n3.display\n4.exit\n";
                cin>>op;
                switch(op)
                {
                        case 1:
                                ob.getdata();
                                break;
                        case 2:
                                ob.bubblesort();
                                break;
                        case 3:
                                ob.display();
                                break;
                        case 4:
                                exit(1);
                }
        }
}


OUTPUT:-


enter the option
1.get data
2.bubble sort
3.display
4.exit
1
enter the number of elements in the array
3
enter the elements
2
1
3

enter the option
1.get data
2.bubble sort
3.display
4.exit
2

enter the option
1.get data
2.bubble sort
3.display
4.exit
3
the sorted list is
1       2       3
enter the option
1.get data
2.bubble sort
3.display
4.exit
4

Wednesday 19 October 2011

AMC Meeting Details



Lab Externals from 27-10-2011 to 2-11-2011
And Mid exams from 3-11-2011 to 5-11-2011.
Final exams from 14-11-2011 to 19-11-2011.

Prepare DS and BE subjects well.

HOD said That “at Present an average 14 members may fail in BE”, So be careful about BE

Prepare Well for Exams.
All the Best. 

Thursday 13 October 2011

Program on insertion and deletion using pointers


#include<iostream>
using namespace std;
template<class T>
class linear_list
{
      T *p;
      int size;
      public:
             void set();
             T get();
             int getindex(T);
             void del(T);
             T findmax();
             T findmin();
             void empty();
             void display();
};
template<class T>
void linear_list<T>::set()
{
     cout<<"\nEnter size of array\n";
     cin>>size;
     p=new T[size];
     cout<<"\nEnter elements\n";
     for(int i=0; i<size; i++)
     cin>>*(p+i);
}
template<class T>
T linear_list<T>::get()
{
     if(size<1)
     {
               cout<<"\nList is empty";
               return -1;
     }
     else
     return *p;
}
template<class T>
int linear_list<T>::getindex(T ele)
{
     if(size<1)
     {
               cout<<"\nList is empty";
               return -1;
     }
     else
     {
         for(int i=0; i<size; i++)
         {
                 if(*(p+i)==ele)
                 return (i+1);
         }
     }
     return -1;
}
template<class T>
void linear_list<T>::del(T ele)
{
     int pos;
     pos=getindex(ele);
     for(int i=pos-1; i<size; i++)
     *(p+i)=*(p+i+1);
     size=size-1;
}
template<class T>
T linear_list<T>::findmax()
{
     int max=*p;
     for(int i=1; i<size; i++)
     {
             if(max<*(p+i))
             {
                            max=*(p+i);
             }
     }
     return max;
}
template<class T>
T linear_list<T>::findmin()
{
     int min=*p;
     for(int i=1; i<size; i++)
     {
             if(min>*(p+i))
             {
                            min=*(p+i);
             }
     }
     return min;
}
template<class T>
void linear_list<T>::empty()
{
     for(int i=0; i<size; i++)
     {
             *(p+i)=0;
     }
}
template<class T>
void linear_list<T>::display()
{
     cout<<"\nArray is\n";
     for(int i=0; i<size; i++)
     cout<<*(p+i)<<" ";
     cout<<"\n";
}
int main()
{
    int ele, pos, option, n=1;
    linear_list<int> ob;
    while(n==1)
    {
              cout<<"\nEnter option";
              cout<<"\n1 set element\n2 get element\n3 getindex of element\n4 delete an element \n5 find maximum element\n6 find minimum element\n7 empty the array\n0 exit program\n";
              cin>>option;
              switch(option)
              {
                            case 1:
                                 ob.set();
                                 ob.display();
                                 break;
                            case 2:
                                 ob.get();
                                 ob.display();
                                 break;
                            case 3:
                                 cout<<"\nEnter element to get index of\n";
                                 cin>>ele;
                                 pos=ob.getindex(ele);
                                 if(pos!=0)
                                 {
                                           cout<<"\nElement found at "<<pos;
                                 }
                                 else
                                 cout<<"\nElement not found";
                                 break;
                            case 4:
                                 cout<<"\nEnter element to be deleted";
                                 cin>>ele;
                                 ob.del(ele);
                                 ob.display();
                                 break;
                            case 5:
                                 cout<<"\nMaximum element is "<<ob.findmax()<<"\n";
                                 break;
                            case 6:
                                 cout<<"\nMinimum element is "<<ob.findmin()<<"\n";
                                 break;
                            case 7:
                                 ob.empty();
                                 ob.display();
                                 break;
                            case 0:
                                 n=0;
                                 break;
              }
    }
    system("pause");
}

Program on insertion and deletion using arrays



#include<iostream>
using namespace std;
template<class T>
class linear_list
{
      T list[20];
      int size;
      public:
             void set();
             T get();
             int getindex(T);
             void del(T);
             T findmax();
             T findmin();
             void empty();
             void display();
};
template<class T>
void linear_list<T>::set()
{
     cout<<"\nEnter size of array\n";
     cin>>size;
     cout<<"\nEnter elements\n";
     for(int i=0; i<size; i++)
     cin>>list[i];
}
template<class T>
T linear_list<T>::get()
{
     if(size<1)
     {
               cout<<"\nList is empty";
               return -1;
     }
     else
     return list[0];
}
template<class T>
int linear_list<T>::getindex(T ele)
{
     if(size<1)
     {
               cout<<"\nList is empty";
               return -1;
     }
     else
     {
         for(int i=0; i<size; i++)
         {
                 if(list[i]==ele)
                 return (i+1);
         }
     }
     return -1;
}
template<class T>
void linear_list<T>::del(T ele)
{
     int pos;
     pos=getindex(ele);
     for(int i=pos-1; i<size; i++)
     list[i]=list[i+1];
     size=size-1;
}
template<class T>
T linear_list<T>::findmax()
{
     int max=list[0];
     for(int i=1; i<size; i++)
     {
             if(max<list[i])
             {
                            max=list[i];
             }
     }
     return max;
}
template<class T>
T linear_list<T>::findmin()
{
     int min=list[0];
     for(int i=1; i<size; i++)
     {
             if(min>list[i])
             {
                            min=list[i];
             }
     }
     return min;
}
template<class T>
void linear_list<T>::empty()
{
     for(int i=0; i<size; i++)
     {
             list[i]=0;
     }
}
template<class T>
void linear_list<T>::display()
{
     cout<<"\nArray is\n";
     for(int i=0; i<size; i++)
     cout<<list[i]<<" ";
     cout<<"\n";
}
int main()
{
    int ele, pos, option, n=1;
    linear_list<int> ob;
    while(n==1)
    {
              cout<<"\nEnter option";
              cout<<"\n1 set element\n2 get element\n3 getindex of element\n4 delete an element \n5 find maximum element\n6 find minimum element\n7 empty the array\n0 exit program\n";
              cin>>option;
              switch(option)
              {
                            case 1:
                                 ob.set();
                                 ob.display();
                                 break;
                            case 2:
                                 ob.get();
                                 ob.display();
                                 break;
                            case 3:
                                 cout<<"\nEnter element to get index of\n";
                                 cin>>ele;
                                 pos=ob.getindex(ele);
                                 if(pos!=0)
                                 {
                                           cout<<"\nElement found at "<<pos;
                                 }
                                 else
                                 cout<<"\nElement not found";
                                 break;
                            case 4:
                                 cout<<"\nEnter element to be deleted";
                                 cin>>ele;
                                 ob.del(ele);
                                 ob.display();
                                 break;
                            case 5:
                                 cout<<"\nMaximum element is "<<ob.findmax()<<"\n";
                                 break;
                            case 6:
                                 cout<<"\nMinimum element is "<<ob.findmin()<<"\n";
                                 break;
                            case 7:
                                 ob.empty();
                                 ob.display();
                                 break;
                            case 0:
                                 n=0;
                                 break;
              }
    }
    system("pause");
}

Basic Electronics Record Experiments List


  1. P-N Junction Diode Characteristics
  2. Zener Diode Characteristics
  3. Half Wave Rectifier
  4. Full Wave Rectifier
  5. Transistor CE Characteristics
  6. Transistor CE Amplifier
  7. Current Series Feedback Amplifier
  8. RC Phase Shift Oscillator
  9. FET Characteristics

Basic Electronics Assignment


















These are few questions of our assignment. I'll upload remaining later.