Thursday, 24 September 2015

Mainly this error comes with $_GET, $_POST and $_REQUEST
Example :
Let us having a index.php page
form name='form1' method='post' action='index.php'
Enter your ID input type='text' value='' name='id'
................
................

and we want to use this 'id' to other page.
Then we use
$id=$_GET['id'];
Then it will show  Notices likes this
Notice: Undefined index: id
First we have to know about what is $_GET
In the php manual,it says “An associative array of variables passed to the current script via the URL parameters”. The word “associative array” clearly tells us what this error is. If we access any array variable which is not set, it will throw an error saying that the index is undefined.
All you need to do to fix it is change this line:
$id = $_GET['id'];
to this:
$id = isset($_GET['id']) ? $_GET['id'] : '';

if you have any query related to php ."skandkr24@gmail.com" -- This is my mail ID 
Free feel to mail me . I'll help you.



Tuesday, 23 October 2012

CLL


/*  CLL as a class */
#include <iostream.h>
#include <conio.h>

class node
 {
public:
int  data;
node *next;
node()   //default constructor
 {
next=NULL;
 }
node(int x)   //parameterised constructor
 {
next=NULL;
data=x;
 }
  /* parameterised constructor will initialize the data field with x */
  };


class linkedlist
 {
node *head; //to store the address of the starting node
public:
linkedlist() //Default constructor
  {
head=NULL;
  }

~linkedlist(); // Destructor to delete a linked list.
void create();
void print();
int count();
int search(int x);
void insertf(int x);//insert at the front
void insertr(int x);//insert at the rear
void Deletef( );//Delete from the front
void Deleter();//Delete from the Rear
 };

 linkedlist:: ~linkedlist()
     {
node *p;
if(head!=NULL)
  {
while(head->next!=head)
  {
p=head->next;
head->next=p->next;
delete p;
  }
delete head;
head=NULL;
   }
    }

void linkedlist:: create()
  {
int x,n,i;
node *p;
cout << "\n Enter no of nodes : ";
cin>>n;
for(i=0;i<n;i++)
  {
cout<<"\n Next Data : ";
cin >> x;
if(head==NULL) // inserting the first node
   {
head=new node(x);
head->next=head;
   }
else
   {
p=new node(x);
p->next=head->next;
head->next=p;
head=p;
   }
  }
  }

 void linkedlist::print()
  {
cout<<"\n Data stored in the linked list : ";
node *p;
if(head==NULL)
return;
p=head->next;
do
  {
cout<<"  "<<p->data;
p=p->next;
  }while(head->next != p);
 }

int linkedlist::count()
 {
int i=0;
node *p;
if(head==NULL)
return 0;
p=head->next;
   do
     {
i++;
p=p->next;
     }while(head->next != p);
   return i;
 }

int linkedlist::search(int x)
 {
int i=0;
node *p;
if(head==NULL)
return -1;
p=head->next;
do
  {
i++;
if(p->data==x)
return i;
p=p->next;
  }while(head->next != p);
return -1;
 }

void linkedlist::insertf(int x)
 {
node *p;
if(head==NULL) // inserting the first node
   {
head=new node(x);
head->next=head;
   }
else
   {
p=new node(x);
p->next=head->next;
head->next=p;
   }
 }

void linkedlist::insertr(int x)
 {
node *p;
if(head==NULL) // inserting the first node
 {
head=new node(x);
head->next=head;
 }
else
 {
p=new node(x);
p->next=head->next;
head->next=p;
head=p;
 }

 }

 void linkedlist::Deletef()
   {
node *p;
if(head->next==head)
 {
delete head;
head=NULL;
 }
else
 {
p=head->next;
head->next=p->next;
delete p;
 }
  }

 void linkedlist::Deleter()
   {
node *p;
if(head->next==head)
 {
delete head;
head=NULL;
 }
else
 {
p=head->next;
while(p->next != head) // locate the predecessor of head node
p=p->next;
p->next=head->next;
delete head;
head=p;
 }
  }



void main()
 {
int op,x,loc;
linkedlist l,l1,l2;
clrscr();
do
{
cout<<"\n\n1)Create\n2)Print\n3)Insert(front)\n4)insert(rear)";
cout<<"\n5)Delete(front)\n6)Delete(rear)\n7)length";
cout<<"\n8)Search\n9)Quit";
cout<<"\nEnter your Choice : ";
cin >> op;
switch(op)
  {
case 1: l.create();break;
case 2: l.print();break;
case 3: cout<<"Enter the data  :"; cin>>x;
l.insertf(x);break;
case 4: cout<<"Enter the data  :"; cin>>x;
l.insertr(x);break;
case 5: l.Deletef();break;
case 6: l.Deleter();break;
case 7: cout << "Length of the linked list = "<<l.count();
break;
case 8: cout << "Enter element to be searched : ";
cin >> x;
loc=l.search(x);
if(loc==-1)
cout << "\n Element not found ";
else
cout << "\n Found at location : "<<loc;
break;
}
      }while(op!=9);
 }

/*

OUTPUT:

1)Create
2)Print
3)Insert(front)
4)insert(rear)
5)Delete(front)
6)Delete(rear)
7)length
8)Search
9)Quit
Enter your Choice : 1

 Enter no of nodes : 4

 Next Data : 1

 Next Data : 2

 Next Data : 3

 Next Data : 4



Enter your Choice : 2

 Data stored in the linked list :   1  2  3  4


Enter your Choice : 3

Enter the data  :55

Enter your Choice : 4

Enter the data  :45

Enter your Choice : 5

Enter your Choice : 6

Enter your Choice : 2

 Data stored in the linked list :   1  2  3  4


Enter your Choice : 7
 Length of the linked list = 4


Enter your Choice : 8
 Enter element to be searched : 4

 Found at location : 4


Enter your Choice : 9

*/

//SLL


//Singly linked list(SLL)....................
#include<iostream.h>
#include<conio.h>
class node
{
 public:
 int data;
 node *next;
 node()
 {
  next=NULL;
 }
 node(int x)
 {
  next=NULL;
  data=x;
 }
};
class linkedlist
{
 node *head;
 public:
       linkedlist()
{
 head=NULL;
}
 
void create();
void print();
void insert(int x,int loc);
void Delete(int loc);
int search(int x);

};

void linkedlist::create()
{
 int x,n,i;
 node *p;
 cout<<"\nEnter no of nodes:";
 cin>>n;
 for(i=0;i<n;i++)
 {
  cout<<"\nNext Data:";
  cin>>x;
  if(head==NULL)
  head=p=new node(x);
  else
   {
    p->next=new node(x);
    p=p->next;
   }
  }
}
void linkedlist::print()
{
 cout<<"\nData stored in a linked list:";
 for(node *p=head;p!=NULL;p=p->next)
 cout<<p->data<<" ";
}
void linkedlist::insert(int x,int loc)
{
node *p=new node(x);
if(loc==1)
{
p->next=head;
head=p;
}
else
{
node *q=head;
for(int i=1;i<loc-1;i++)
if(q!=NULL)
 q=q->next;
 else
   {
      cout<<"OVERFLOW";
      return;
   }
 p->next=q->next;
 q->next=p;
}
}
void linkedlist::Delete(int loc)
{
 node *p,*q;
 int i;
 if(loc==1)
 {
  p=head;
  head=head->next;
  delete p;
 }
 else
 {
 q=head;
 for(i=1;i<loc-1;i++)
 if(q->next==NULL)
 {
  cout<<"\nUnderflow........";
  return;
 }
 else
    q=q->next;
    p=q->next;
    q->next=p->next;
    delete p;
    }
    }
int linkedlist::search(int x)
{
 int i=0;
 for(node *p=head;p!=NULL;p=p->next)
 {
  if(p->data==x)
  return(i);
  i++;
 }
  return -1;
}
void main()
{
 int op,x,loc;
 clrscr();
 linkedlist l;
 do
 {
  cout<<"\n1)Create\n2)print\n3)Insert\n4)Delete\n5)search\n6)quit";
  cout<<"\nEnter your choice:";
  cin>>op;
  switch(op)
  {
   case 1:l.create();
   break;
   case 2:l.print();
   break;
   case 3:cout<<"\nEnter the location:";
 cin>>loc;
 cout<<"\nEnter the data:";
 cin>>x;
 l.insert(x,loc);
 break;
   case 4:cout<<"\nEnter the location:";
 cin>>loc;
 l.Delete(loc);
 break;
   case 5:cout<<"\nEnter the element to be searched:";
 cin>>x;
 loc=l.search(x);
 if(loc==-1)
 cout<<"\nElement not found..";
 else
 cout<<"\nfound at location:"<<loc+1;
 break;

  }
 }while(op!=6);getch();
 }

Monday, 24 October 2011

Idea about "Change"....

Change is inspiring.
The best change often starts as one simple thought.

Change is positive.
It brings an enduring transformation.

Change is inevitable.
The sooner we open up to it, the better.

Change is essence of life.
If we don't change, we don't grow.

change is future.
And it is here right now.

Be the change you want to see!

Wednesday, 19 October 2011

"C program for Student Database from linked list"

/*PROBLEM DEFINATION : Implement the Mini Project of Student Database using Linked list for following requirements:
    a. Creation of Student Database in memory containing student ID, Name, Name
        Initials, Address, Contact No and Date of Birth .
    b. Insertion, Deletion, Modification of student record for a given student ID.
    c. Sorting on name initials and searching a particular student record on name initials
  */

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<dos.h>

struct stud
{
 int rn,id,ph;
 char add[30],na[20],d[15],in[5];
 struct stud *next;
}*h=NULL,*p,*q,*t;

void add()
{
  clrscr();
  p =(stud *)malloc(sizeof(stud));
  printf("\nEnter the Initials of Student : ");
  scanf("%s",&p->in);
  printf("\nEnter the Last Name of Student : ");
  scanf("%s",&p->na);
  printf("\nEnter the ID of Student : ");
  scanf("%d",&p->id);
  printf("\nEnter the Roll No. of Student : ");
  scanf("%d",&p->rn);
  printf("\nEnter the Ph No. of Student : ");
  scanf("%d",&p->ph);
  printf("\nEnter the Address of Student : ");
  scanf("%s",&p->add);
  printf("\nEnter the D.O.B. of Student(dd/mm/yyyy) : ");
  scanf("%s",&p->d);

  p->next=NULL;

  if(h==NULL)
  {
   h=p;
  }
  else
  {
    q=h;
    while(q->next!=NULL)
    q=q->next;
    q->next=p;
  }
  ts++;
}

void addAt(int r)
{
 q=h;
 while(q->rn!=r || q==NULL)
  q=q->next;
 if(q->rn==r)
 {
  clrscr();
  p =(stud *)malloc(sizeof(stud));
  printf("\nEnter the Initials of Student : ");
  scanf("%s",&p->in);
  printf("\nEnter the Last Name of Student : ");
  scanf("%s",&p->na);
  printf("\nEnter the ID of Student : ");
  scanf("%d",&p->id);
  printf("\nEnter the Roll No. of Student : ");
  scanf("%d",&p->rn);
  printf("\nEnter the Ph No. of Student : ");
  scanf("%d",&p->ph);
  printf("\nEnter the Address of Student : ");
  scanf("%s",&p->add);
  printf("\nEnter the D.O.B. of Student(dd/mm/yyyy) : ");
  scanf("%s",&p->d);
  p->next=q->next;
  q->next=p;
  ts++;
 }
 else
 {
  printf("\n\nRecord Not Found.");
 }
}


void delAt(int r)
{
 q=h;
 while((q->next)->rn!=r || q==NULL)
  q=q->next;
 if((q->next)->rn==r)
 {
  q->next=(q->next)->next;
  printf("\n\nRecord Deleted.");
  ts--;
 }
 else
  printf("\n\nRecord Not Found.");
}

void modAt(int id)
{
 q=h;
 int ch;
 while(q->id!=id && q!=NULL)
  q=q->next;
 if(q->id==id)
 {
  clrscr();
  printf("******* MODIFY *******\n1.Name Initials\n2.Last Name");
  printf("\n3.Roll No.\n4.Phone\n5.Add\n6.D.O.B.:\nEnter choice: ");
  scanf("%d",&ch);
  switch(ch)
  {
  case 1 :  printf("\n\nEnter the Initials of Student : ");
          scanf("%s",&q->in);break;
  case 2 :  printf("\nEnter the Last Name of Student : ");
          scanf("%s",&q->na);break;
  case 3 :  printf("\nEnter the Roll No. of Student : ");
          scanf("%d",&q->rn);break;
  case 4 :  printf("\nEnter the Ph No. of Student : ");
          scanf("%d",&q->ph);break;
  case 5 :  printf("\nEnter the Address of Student : ");
          scanf("%s",&q->add);break;
  case 6 :  printf("\nEnter the D.O.B. of Student(dd/mm/yyyy) : ");
          scanf("%s",&q->d);break;
  }
 }
 else
  printf("\nRecord not Found.");
}

void search(char ni[5])
{
 int flag=0;
 q=h;
 clrscr();
 while(q!=NULL)
 {
  if(stricmp(q->in,ni)==0)
  {
  flag=1;
  printf("\n\nInitals of Student :   %s ",q->in);
  printf("\n\nLast Name of Student : %s ",q->na);
  printf("\n\nID of Student :        %d ",q->id);
  printf("\n\nRoll No. of Student :  %d",q->rn);
  printf("\n\nPh No. of Student :    %d",q->ph);
  printf("\n\nAddress of Student :   %s",q->add);
  printf("\n\nD.O.B. of Student :    %s",q->d);
  printf("\n\n\n");
  }
  q=q->next;
 }
 if(flag==0)
  printf("\n\nNo Match Found.");
}

void sort()
{
 p=h;
 while(p!=NULL)
 {
  q=h;
  while(q!=NULL)
  {
   if(stricmp(q->in,(q->next)->in)>0)
   {
    strcpy(t->in,q->in);
    strcpy(t->na,q->na);
    t->id=q->id;
    t->rn=q->rn;
    t->ph=q->ph;
    strcpy(t->add,q->add);
    strcpy(t->d,q->d);


    strcpy(q->in,(q->next)->in);
    strcpy(q->na,(q->next)->na);
    q->id=  (q->next)->id;
    q->rn=  (q->next)->rn;
    q->ph=  (q->next)->ph;
    strcpy(q->add,(q->next)->add);
    strcpy(q->d,(q->next)->d);

    strcpy((q->next)->in,t->in);
    strcpy((q->next)->na,t->na);
    (q->next)->id = t->id;
    (q->next)->rn = t->rn;
    (q->next)->ph = t->ph;
    strcpy((q->next)->add,t->add);
    strcpy((q->next)->d,t->d);

   }
   q=q->next;
  }
  p=p->next;
 }

}

void disp()
{
 p=h;
 clrscr();
 while(p!=NULL)
 {
  printf("\nInitals of Student :   %s ",p->in);
  printf("\nName of Student :      %s ",p->na);
  printf("\nID of Student :        %d ",p->id);
  printf("\nRoll No. of Student :  %d",p->rn);
  printf("\nPh No. of Student :    %d",p->ph);
  printf("\nAddress of Student :   %s",p->add);
  printf("\nD.O.B. of Student :    %s",p->d);
  printf("\n\n");
  p=p->next;
 }
}

void main()
{
 int ch=0,r;
 char ni[5];
 clrscr();
 while(ch!=8)
 {
  clrscr();
  printf("1.Add the Record.\n\n2.Add Record at Locn.\n\n3.Delete Record.");
  printf("\n\n4.Modify Record.\n\n5.Search Record.\n\n6.Sort Records.");
  printf("\n\n7.Display\n\n8.Exit");
  printf("\n\nEnter the Choice: ");
  scanf("%d",&ch);
   switch(ch)
   {
    case 1:
    add();
    break;

    case 2:
    printf("\nEnter the Roll No. : ");
    scanf("%d",&r);
    addAt(r);
    break;

    case 3:
    printf("\nEnter the Roll No. : ");
    scanf("%d",&r);
    delAt(r);
    break;

    case 4:
    printf("\nEnter the ID : ");
    scanf("%d",&r);
    modAt(r);
    break;

    case 5:
    printf("\nEnter the Initials : ");
    scanf("%s",&ni);
    search(ni);
    break;

    case 6:
    sort();
    printf("\n\nSorted");
    break;
    case 7:
    disp();
    break;
   }
 getch();
 }
 getch();
}
*/
OUTPUT :
==========

1.Add the Record.
2.Add Record at Locn.
3.Delete Record.
4.Modify Record.
5.Search Record.
6.Sort Records.
7.Display
8.Exit

Enter the Choice: 1
Enter the Initials of Student : T.T.
Enter the Last Name of Student : MOJAD
Enter the ID of Student : 001
Enter the Roll No. of Student : 1
Enter the Ph No. of Student : 1234
Enter the Address of Student : qwer
Enter the D.O.B. of Student(dd/mm/yyyy) :10/12/1988

1.Add the Record.
2.Add Record at Locn.
3.Delete Record.
4.Modify Record.
5.Search Record.
6.Sort Records.
7.Display
8.Exit

Enter the Choice: 7
Initals of Student :   T.T.
Name of Student :      MOJAD
ID of Student :        1
Roll No. of Student :  1
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    10/12/1988

Initals of Student :   A.M.
Name of Student :      Mehata
ID of Student :        2
Roll No. of Student :  2
Ph No. of Student :    12345
Address of Student :   abde
D.O.B. of Student :    10/12/1990

Initals of Student :   S.M.
Name of Student :      Mane
ID of Student :        3
Roll No. of Student :  3
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    12/12/1989

1.Add the Record.
2.Add Record at Locn.
3.Delete Record.
4.Modify Record.
5.Search Record.
6.Sort Records.
7.Display
8.Exit

Enter the Choice: 2
Enter the Roll No. : 2
Enter the Initials of Student : Z.Z.
Enter the Last Name of Student : Shaikh
Enter the ID of Student : 005
Enter the Roll No. of Student : 4
Enter the Ph No. of Student : 1234
Enter the Address of Student : qwer
Enter the D.O.B. of Student(dd/mm/yyyy) : 14/3/1991

Initals of Student :   T.T.
Name of Student :      MOJAD
ID of Student :        1
Roll No. of Student :  1
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    10/12/1988

Initals of Student :   A.M.
Name of Student :      Mehata
ID of Student :        2
Roll No. of Student :  2
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    10/12/1990

Initals of Student :   Z.Z.
Name of Student :      Shaikh
ID of Student :        5
Roll No. of Student :  4
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :   14/3/1991

Initals of Student :   S.M.
Name of Student :      Mane
ID of Student :        3
Roll No. of Student :  3
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    12/12/1989

1.Add the Record.
2.Add Record at Locn.
3.Delete Record.
4.Modify Record.
5.Search Record.
6.Sort Records.
7.Display
8.Exit

Enter the Choice: 5
Enter the Initials : a.m.

Initals of Student :   A.M.
Last Name of Student : Mehata
ID of Student :        2
Roll No. of Student :  2
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    10/12/1990

1.Add the Record.
2.Add Record at Locn.
3.Delete Record.
4.Modify Record.
5.Search Record.
6.Sort Records.
7.Display
8.Exit

Enter the Choice: 4
Enter the ID : 001

******* MODIFY *******
1.Name Initials
2.Last Name
3.Roll No.
4.Phone
5.Add
6.D.O.B.:
Enter choice: 1

Enter the Initials of Student : T.D.

Initals of Student :   T.D.
Name of Student :      MOJAD
ID of Student :        1
Roll No. of Student :  1
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    10/12/1988

Initals of Student :   A.M.
Name of Student :      Mehata
ID of Student :        2
Roll No. of Student :  2
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    10/12/1990

Initals of Student :   Z.Z.
Name of Student :      Shaikh
ID of Student :        5
Roll No. of Student :  4
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    14/3/1991

Initals of Student :   S.M.
Name of Student :      Mane
ID of Student :        3
Roll No. of Student :  3
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    12/12/1989

1.Add the Record.
2.Add Record at Locn.
3.Delete Record.
4.Modify Record.
5.Search Record.
6.Sort Records.
7.Display
8.Exit

Enter the Choice: 6
Sorted
Initals of Student :   A.M.
Name of Student :      Mehata
ID of Student :        2
Roll No. of Student :  2
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    10/12/1990

Initals of Student :   S.M.
Name of Student :      Mane
ID of Student :        3
Roll No. of Student :  3
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    12/12/1989

Initals of Student :   T.D.
Name of Student :      MOJAD
ID of Student :        1
Roll No. of Student :  1
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    10/12/1988

Initals of Student :   Z.Z.
Name of Student :      Shaikh
ID of Student :        5
Roll No. of Student :  4
Ph No. of Student :    1234
Address of Student :   qwer
D.O.B. of Student :    14/3/1991
*/

"C program for Circular queue"

/* Program for showing various operations on a Circular queue  represented
   using linked list.
   */

#include<stdio.h>
#include<conio.h>
typedef struct node
 {
   int data;
   struct node *next;
 }node;
void init(node **R);
void enqueue(node **R,int x);
int dequeue(node **R);
int empty(node *rear);
void print(node *rear);
int front_element(node *rear);
int rear_element(node *rear);
void main()
{
 int x,option;
 int n = 0,i;
 node *rear;
 init(&rear);
 clrscr();
 do
   {
      printf("\n1]Insert\t2]Delete\t3]Print");
      printf("\t4]Front element\t5]Rear Element\t6]Quit");
      printf("\nEnter your option:  ");
      scanf("%d",&option);
      switch(option)
      {
        case 1: printf("\nEnter queue data : ");
            scanf("\n %d",&x);
            enqueue(&rear,x);
            break;
        case 2 : if(! empty(rear))
            {
              x=dequeue(&rear);
              printf("\n Element deleted = %d",x);
            }
             else
              printf("\n Uderflow..... Cannot deleted");
             break;
        case 3 : print(rear);
             break;
        case 4 :if(!empty(rear))
               printf("\nFront Element = %d",front_element(rear));
            else
               printf("\nQueue is empty");
            break;
        case 5 :if(!empty(rear))
               printf("\nRear Element = %d",rear_element(rear));
            else
               printf("\nQueue is empty");
            break;
     }
  }while(option != 6);

 }

 void init(node **R)
    {
      *R = NULL;
    }

 void enqueue(node **R,int x)
    {
     node *p;
     p = (node *)malloc(sizeof(node));
     p->data = x;
     if(empty(*R))
    {
      p->next = p;
      *R = p;
    }
     else
       {
      p->next = (*R)->next;
      (*R)->next = p;
      (*R) = p;
       }
    }

int dequeue(node **R)
  {
    int x;
    node *p;
    p=(*R)->next;
    x=p->data;
    if(p->next == p)
     {
         *R = NULL;
         free(p);
         return(x);
     }
   (*R)->next = p->next;
   free(p);
   return(x);
 }

void print(node *rear)
  {
   node *p;
   if(!empty(rear))
      {
      p = rear->next;
      }
   else
     {
       printf("\nQueue is empty");
       return;
     }

   printf("\n");
   do
     {
    printf("%d  ",p->data);
    p = p->next;
     }while(p != rear->next);
  }

int empty(node *P)
  {
    if(P->next== NULL)
        return(1);
    return(0);
  }

int front_element(node *rear)
  {
     return(rear->next->data);
  }

int rear_element(node *rear)
  {
     return(rear->data);
  }
  /*
  OUTPUT:-

1]Insert        2]Delete        3]Print 4]Front element 5]Rear Element  6]Quit 
Enter your option:  1                                                          
                                                                               
Enter queue data : 23                                                          
                                                                               
1]Insert        2]Delete        3]Print 4]Front element 5]Rear Element  6]Quit 
Enter your option:  1                                                          
                                                                               
Enter queue data : 34                                                          
                                                                               
1]Insert        2]Delete        3]Print 4]Front element 5]Rear Element  6]Quit 
Enter your option:  1                                                          
                                                                               
Enter queue data : 45                                                          
                                                                               
1]Insert        2]Delete        3]Print 4]Front element 5]Rear Element  6]Quit 
Enter your option:  3                                                          
                                                                               
23  34  45                                                                     
1]Insert        2]Delete        3]Print 4]Front element 5]Rear Element  6]Quit 
Enter your option:  4                                                          
                                                                               
Front Element = 23                                                             
1]Insert        2]Delete        3]Print 4]Front element 5]Rear Element  6]Quit 
Enter your option:  5                                                          
                                                                               
Rear Element = 45                                                              
1]Insert        2]Delete        3]Print 4]Front element 5]Rear Element  6]Quit 
Enter your option:  2                                                          
                                                                               
 Element deleted = 23                                                          
1]Insert        2]Delete        3]Print 4]Front element 5]Rear Element  6]Quit 
Enter your option:  6
*/
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               

"C program for Stack as ADT"

/*  IMPLEMENT STACK AS AN ADT USING ARRAY. USE THIS ADT TO
        PERFORM EXPRESSION CONVERSION & EVALUATION (INFIX TO
        POSTFIX,INFIX TO PREFIX,PREFIX TO INFIX,PREFIX TO POSTFIX,
        POSTFIX TO INFIX & POSTFIX TO PREFIX)
   */ .


  #include<stdio.h>
  #include<conio.h>
  #include<ctype.h>
  #include<string.h>
  #define MAX 20
  void in2post();
  void in2pre();
  void post2in();
  void pre2in();
  void post2pre();

  char s[MAX];
  char s1[MAX][MAX];
  int top=-1;
  void main()
   {
    char e[MAX];
    int choice;
    char ch;
    do
    {
     clrscr();
     printf("\n\n\t================= GIVEN MENU FOR STACK=================");
     printf("\n\n\t 1.Infix to Postfix");
     printf("\n\n\t 2.Infix to Prefix");
     printf("\n\n\t 3.Postfix to Infix");
     printf("\n\n\t 4.Prefix to Infix");
     printf("\n\n\t 5.Postfix to Prefix");
     printf("\n\n\t 6.EXIT");
     printf("\n\n\t Enter the Choice(1,2,3,4,5,6): ");
     scanf("%d",&choice);
     printf("\n\n\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
     switch(choice)
      {
    case 1:
           printf("\n\n\t*** INFIX TO POSTFIX ***");
           printf("\n\n\t Enter the Infix Exp: ");
           scanf("%s",&e);
           in2post(e);
           break;

    case 2:
           printf("\n\n\t*** INFIX TO PREFIX ***");
           printf("\n\n\t Enter the Infix Exp: ");
           scanf("%s",&e);
           in2pre(e);
           break;

    case 3:
           printf("\n\n\t*** POSTFIX TO INFIX ***");
           printf("\n\n\t Enter the Postfix Exp: ");
           scanf("%s",&e);
           post2in(e);
           break;

    case 4:
           printf("\n\n\t*** PREFIX TO INFIX ***");
           printf("\n\n\t Enter the Prefix Exp: ");
           scanf("%s",&e);
           pre2in(e);
           break;

    case 5:
           printf("\n\n\t*** POSTFIX TO PREFIX ***");
           printf("\n\n\t Enter the Postfix Exp: ");
           scanf("%s",&e);
           post2pre(e);
           break;

    case 6:
           exit(0);
           break;

    default:
        printf("\n\n\t*** INVALID CHOICE ***");
      }
      printf("\n\n\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
      printf("\n\n\t Do you want to continue(y/n): ");
      ch=getche();
    }while(ch=='Y'||ch=='y');
    getch();
   }


  void push(char c)
   {
    if(top>=MAX-1)
     {
       printf("\n\n\T Stack is Full...");
       return ;
     }
    else
     {
      top++;
      s[top]=c;
     }
   }

  char pop()
   {
     char c;
     if(top<0)
      {
    return NULL;
      }
     else
      {
    c=s[top];
    top--;
    return(c);
      }
   }

  int prior(char c)
   {
     if(c=='$'||c=='^')
     return 3;
     if(c=='*'||c=='/'||c=='%')
     return 2 ;
     else
      {
       if(c=='+'||c=='-')
       return 1 ;
       else
       return 0 ;
      }
   }

  void in2post(char e[MAX])
   {
    int i=0,p=0;
    char pe[MAX],c,opr;
    while(e[i]!='\0')
     {
      c=e[i];
      if(isalpha(c))
      pe[p++]=c;
      if(c=='(')
      push(c);
      if(c=='*'||c=='/'||c=='+'||c=='-'||c=='%'||c=='$'||c=='^')
       {
    if(top!=-1)
     {
      opr=pop();
      while(prior(opr)>=prior(c))
       {
         pe[p++]=opr;
         opr=pop();
       }
      push(opr);
      push(c);
     }
    else
     push(c);
       }
      if(c==')')
       {
    opr=pop();
    while(opr!='(')
     {
      pe[p++]=opr;
      opr=pop();
     }
       }
      i++;
      }
      while(top!=-1)
      pe[p++]=pop();;
      pe[p++]='\0';
      printf("\n\n\t %s",pe);
   }


  void in2pre(char e[])
   {
    char pe[MAX],c,opr;
    int i=0,p=0;
    strrev(e);
    while(e[i]!='\0')
     {
      c=e[i];
      if(isalpha(c))
      pe[p++]=c;
      if(c==')')
      push(c);
      if(c=='*'||c=='/'||c=='+'||c=='-'||c=='%'||c=='$'||c=='^')
       {
    if(top!=-1)
     {
      opr=pop();
      while(prior(opr)>prior(c))
       {
        pe[p++]=opr;
        opr=pop();
       }
      push(opr);
      push(c);
     }
    else
    push(c);
       }
      if(c=='(')
       {
    opr=pop();
    while(opr!=')')
     {
      pe[p++]=opr;
      opr=pop();
     }
       }
       i++;
      }
      while(top!=-1)
      pe[p++]=pop();
      pe[p++]='\0';
      strrev(pe);
      printf("\n\n\t Prefix Exp is: %s",pe);
    }


  void post2in(char post[])
   {
    char in[20],p1[20],p2[20],ch,o,t[10];
    int i=0;
    while(post[i]!='\0')
     {
      ch=post[i];
      if(isalpha(ch))
       {
     t[0]=ch;
     t[1]='\0';
     top++;
     strcpy(s1[top],t);
       }
      if(ch=='*'||ch=='^'||ch=='+'||ch=='-'||ch=='/')
       {
     strcpy(p2,s1[top]);
     top--;
     strcpy(p1,s1[top]);
     top--;
     t[0]=ch;
     t[1]='\0';
     strcat(p1,t);
     strcat(p1,p2);
     top++;
     strcpy(s1[top],p1);
       }
       i++;
     }

    strcpy(in,s1[top]);
    printf("\n\n\t Infix Exp is: %s",in);
   }

  void pre2in(char pre[])
   {
    char in[MAX],p1[MAX],p2[MAX],ch,o,t[10];
    int i=0;
    strrev(pre);
    while(pre[i]!='\0')
     {
      ch=pre[i];
      if(isalpha(ch))
       {
     t[0]=ch;
     t[1]='\0';
     top++;
     strcpy(s1[top],t);
       }
      if(ch=='*'||ch=='^'||ch=='+'||ch=='-'||ch=='/')
       {
     strcpy(p2,s1[top]);
     top--;
     strcpy(p1,s1[top]);
     top--;
     t[0]=ch;
     t[1]='\0';
     strcat(p1,t);
     strcat(p1,p2);
     top++;
     strcpy(s1[top],p1);
       }
       i++;
     }
    strcpy(in,s1[top]);
    strrev(in);
    printf("\n\n\t Infix Exp is: %s",in);
   }


  void post2pre(char post[])
   {
    char in[MAX],p1[20],p2[20],ch,o,t[10];
    int i=0;
    while(post[i]!='\0')
     {
      ch=post[i];
      if(isalpha(ch))
       {
    t[0]=ch;
    t[1]='\0';
    top++;
    strcpy(s1[top],t);
       }
      if(ch=='*'||ch=='^'||ch=='+'||ch=='-'||ch=='/')
       {
    strcpy(p2,s1[top]);
    top--;
    strcpy(p1,s1[top]);
    top--;
    t[0]=ch;
    t[1]='\0';
    strcat(t,p1);
    strcat(t,p2);
    top++;
    strcpy(s1[top],t);
       }
       i++;
     }
     strcpy(in,s1[top]);
     printf("\n\n\t Prefix Exp is: %s",in);

   }

/*
OUTPUT:-


         GIVEN MENU FOR STACK
 1.Infix to Postfix      2.Infix to Prefix       3.Postfix to Infix      4.Prefi
x to Infix       5.Postfix to Prefix     6.EXIT
        Enter the Choice(1,2,3,4,5,6): 1

 INFIX TO POSTFIX
 Enter the Infix Exp: a+b*c


         abc*+



      
        Enter the Choice(1,2,3,4,5,6): 2

INFIX TO PREFIX
 Enter the Infix Exp: a+c*b/d

Prefix Exp is: +a/*cbd
 Do you want to continue(y/n):y


        Enter the Choice(1,2,3,4,5,6): 3

 POSTFIX TO INFIX
 Enter the Postfix Exp: a+*c/b-d

 Infix Exp is: d
 Do you want to continue(y/n):y


        Enter the Choice(1,2,3,4,5,6): 4

 PREFIX TO INFIX
 Enter the Prefix Exp: a?b+c*d

 Infix Exp is: a
 Do you want to continue(y/n):y


        
        Enter the Choice(1,2,3,4,5,6):5

POSTFIX TO PREFIX
 Enter the Postfix Exp: a^b+c-d/e

 Prefix Exp is: e
 Do you want to continue(y/n):y

*/






























































































































































"C program for polynomial using Linked list"

/*Title :-Represent a Polynomal using a circular linked list and write menu driven program to
  perform addition,multiplication and evaluation.

  */


#include <stdio.h>
#include <conio.h>
#include <math.h>

typedef struct  node
 { int power;
   float coeff;
   struct node *next;
 }node;

      node *  insert(node *head,int power1,float coeff1);
      node *  create();
      node *  padd(node *p1,node *p2);
      node *  pmul(node *p1,node *p2);
      float eval(node *p1,float x);
      void print(node *head);


node *insert(node *head,int power1,float coeff1)
      {  node *p,*q;
     /*terms are store in increasing order of power*/
     /*pointer is used to locate the correct place of insertion.
       pointer p is used to store the address of the node created for
       the current term.If a term with same power is found,coefficients
       are added*/
       p=(node*) malloc(sizeof(node));
       p->power=power1;
       p->coeff=coeff1;
       p->next=NULL;
       if(head==NULL)
     {
          head=p;
          head->next=head;
          return(head);
     }
       if(power1>head->power)
      {
          p->next=head->next;
          head->next=p;
          head=p;
          return(head);
      }
       if(power1==head->power)
      {
          head->coeff=head->coeff+coeff1;
          return(head);
      }

     q=head;
     while(q->next!=head && power1>=q->next->power)
           q=q->next;
     if(p->power==q->power)
           q->coeff=q->coeff+coeff1;
     else
       {
           p->next=q->next;
           q->next=p;
       }
    return(head);
  }


 node *create()
   {
       int n,i,power1;
       float coeff1;
       node *head=NULL;
       printf("\nEnter No. of Terms:");
       scanf("%d",&n);
       printf("\nenter a term as a tuple of (power,coefficient) : ");
       for(i=1;i<=n;i++)
     {   scanf("%d%f",&power1,&coeff1);
         head=insert(head,power1,coeff1);
     }
       return(head);
  }

 node * padd(node *p1,node *p2)
 {   node *p;
     node *head=NULL;
     int power;float coeff;
     p=p1->next;
     do
     {
         head=insert(head,p->power,p->coeff);
         p=p->next;
     } while(p!=p1->next);
     p=p2->next;
     do
     {
         head=insert(head,p->power,p->coeff);
         p=p->next;
     } while(p!=p2->next);
     return(head);
  }

 node *pmul(node *p1,node *p2)
 {   node *head1,*head2;
     node *head=NULL;
     head2=p2->next;
      do
       {  head1=p1->next;
      do
        {
 //    for(p=head1;p!=NULL;p=p->next)
         head=insert(head,head1->power+head2->power,head1->coeff * head2->coeff);
         head1=head1->next;
       }while(head1!=p1->next);
    head2=head2->next;
       }while(head2!=p2->next);
     return(head);
 }

 float eval(node *head,float x)
 {  float value=0.00;
    node *p;
    p=head->next;
    do
       {  value=value+p->coeff * pow(x,p->power);
      p=p->next;
       }while(p!=head->next);
    return(value);
 }

 void print( node *head)
 {  node *p;
    p=head->next;
    printf("\n");
    do
     {
    printf("%6.2fx^%d   ",p->coeff,p->power);
    p=p->next;
     }while(p!=head->next);
 }


 void main()
 { node *p1,*p2,*p3;
   int op;
   float value,x;
   p1=p2=p3=NULL;
   clrscr();
   do
     { printf("\n1)Create first polynomial");
       printf("\n2)Create second polynomial");
       printf("\n3)Print first polynomial");
       printf("\n4)Print second polynomial");
       printf("\n5)Add\n6)Multiply\n7)Evaluate First Polynomial\n8)Quit");
       printf("\nEnter Your Choice: ");
       scanf("%d",&op);
       switch(op)
    { case 1: p1=create();break;
      case 2: p2=create();break;
      case 3: print(p1);break;
      case 4: print(p2);break;
      case 5: p3=padd(p1,p2);
          print(p3);break;
      case 6: p3=pmul(p1,p2);
          print(p3);break;
      case 7: printf("\nEnter the value of X:");
          scanf("%f",&x);
          value=eval(p1,x);
          printf("\nEvaluated value = %6.2f",value);
          break;
      }
       }while(op!=8);
 }

 /*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OUTPUT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


1)Create first polynomial
2)Create second polynomial
3)Print first polynomial
4)Print second polynomial
5)Add
6)Multiply
7)Evaluate First Polynomial
8)Quit

Enter Your Choice: 1

Enter No. of Terms:2

enter a term as a tuple of (power,coefficient) : 1 3 2 1

Enter Your Choice: 3

  3.00x^1     1.00x^2


Enter Your Choice: 2

Enter No. of Terms:2

enter a term as a tuple of (power,coefficient) : 5 1 6 2


Enter Your Choice: 5

  3.00x^1     1.00x^2     1.00x^5     2.00x^6
1)Create first polynomial


Enter Your Choice: 6

  3.00x^6     7.00x^7     2.00x^8

Enter Your Choice: 7

Enter the value of X:2

Evaluated value =  10.00
 */

Few Linux App & commands which is going to used to Build AOSP(Android Open Source Project) Source Code

1. sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32n...