Showing posts with label DATA STRUCTURE. Show all posts
Showing posts with label DATA STRUCTURE. Show all posts

Sunday, 13 April 2014

Circular Singly Linked List

PROGRAM:

#include<stdio.h>
#include<conio.h>
#include<malloc.h>
typedef struct node
{
int data;
struct node *next;
}node;
node *head=NULL,*newn,*temp,*t;
void insert();
void del();
void display();
void main()
{
int ch;
clrscr();
printf("\n\n$$$ CIRCULARLY LINKED LIST $$$\n\n");
while(1)
{
printf("\n\nCIRCULARLY LINKED LIST OPERATIONS ARE\n\n");
printf("1.Insert\n2.Delete\n3.Display\n4.Exit\n");
printf("Enter Ur Choice:\t");
scanf("%d",&ch);
switch(ch)
{
case 1:insert();break;
case 2:del();break;
case 3:display();break;
case 4:exit(0);
default:printf("Enter the correct option\n");
break;
}
}
}
void insert()
{
int no,op;
newn=(node *)malloc(sizeof(node));
printf("Enter the element to be inserted:\t");
scanf("%d",&newn->data);
printf("1.Insert at First\n2.Insert at Middle\n3.Insert at Last\n");
printf("Enter the option:\t");
scanf("%d",&op);
switch(op)
{
case 1:
if(head==NULL)
{
head=newn;
newn->next=newn;
}
else
{
temp=head;
while(temp->next!=head)
{
temp=temp->next;
}
temp->next=newn;
newn->next=head;
head=newn;
}
break;

case 2:
if(head->next==NULL)
{
printf("Single node entry so insertion is not allowed in the middle\n");
}
else
{
printf("Enter the data after which the element to be inserted:\t");
scanf("%d",&no);
temp=head;
while(temp->data!=no)
{
temp=temp->next;
}
newn->next=temp->next;
temp->next=newn;
}
break;

case 3:
if(head==NULL)
{
head=newn;
newn->next=newn;
}
else
{
temp=head;
while(temp->next!=head)
{
temp=temp->next;
}
temp->next=newn;
newn->next=head;
}
break;
}
}
void del()
{
int op,no;
if(head==NULL)
{
printf("List is empty\n");
}
else
{
printf("1.Deletion at first\n2.Deletion at middle\n3.Deletion at last\n");
printf("Enter your choice:\t");
scanf("%d",&op);
switch(op)
{
case 1:
if(head->next==head)
{
printf("The deleted element is: %d",head->data);
head=NULL;
}
else
{
temp=head;
printf("The deleted element is: %d",temp->data);
while(temp->next!=head)
{
temp=temp->next;
}
temp->next=head->next;
head=head->next;
free(temp);
}
break;

case 2:
if(head->next==head)
{
printf("Single node entry cannot perform deletion in the middle\n");
}
else
{
printf("Enter the element to be deleted:\t");
scanf("%d",&no);
temp=head;
while(temp->data!=no)
{
t=temp;
temp=temp->next;
}
printf("The deleted element is: %d",temp->data);
t->next=temp->next;
free(temp);
}
break;

case 3:
if(head->next==head)
{
printf("The deleted element is: %d",head->data);
head=NULL;
}
else
{
temp=head;
while(temp->next!=head)
{
t=temp;
temp=temp->next;
}
printf("The deleted element is: %d",temp->data);
t->next=head;
free(temp);
}
break;
}
}
}
void display()
{
if(head==NULL)
{
printf("List is empty\n");
}
else
{
temp=head;
printf("The elements in a list are:\n");
do
{
printf("%d\n",temp->data);
temp=temp->next;
}while(temp!=head);
}

}


OUTPUT:

$$$ CIRCULARLY LINKED LIST $$$

CIRCULARLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        1
Enter the element to be inserted:       11
1.Insert at First
2.Insert at Middle
3.Insert at Last
Enter the option:       1

CIRCULARLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        1
Enter the element to be inserted:       33
1.Insert at First
2.Insert at Middle
3.Insert at Last
Enter the option:       3

CIRCULARLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        1
Enter the element to be inserted:       22
1.Insert at First
2.Insert at Middle
3.Insert at Last
Enter the option:       2
Enter the data after which the element to be inserted:  11

CIRCULARLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        3
The elements in a list are:
11
22
33

CIRCULARLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        2
1.Deletion at first
2.Deletion at middle
3.Deletion at last
Enter your choice:      2
Enter the element to be deleted:        22
The deleted element is: 22

CIRCULARLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        3
The elements in a list are:
11
33

CIRCULARLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        4

Doubly Linked List

PROGRAM:

#include<stdio.h>
#include<conio.h>
#include<malloc.h>
typedef struct node
{
int data;
struct node *next,*prev;
}node;
node *head=NULL,*newn,*temp,*t;
void insert();
void del();
void display();
void main()
{
int ch;
clrscr();
printf("\n\n$$$ DOUBLY LINKED LIST $$$\n\n");
while(1)
{
printf("\n\nDOUBLY LINKED LIST OPERATIONS ARE\n\n");
printf("1.Insert\n2.Delete\n3.Display\n4.Exit\n");
printf("Enter Ur Choice:\t");
scanf("%d",&ch);
switch(ch)
{
case 1:insert();break;
case 2:del();break;
case 3:display();break;
case 4:exit(0);
default:printf("Enter the correct option\n");
break;
}
}
}
void insert()
{
int no,op;
newn=(node *)malloc(sizeof(node));
printf("Enter the element to be inserted:\t");
scanf("%d",&newn->data);
printf("1.Insert at First\n2.Insert at Middle\n3.Insert at Last\n");
printf("Enter the option:\t");
scanf("%d",&op);
switch(op)
{
case 1:
if(head==NULL)
{
newn->next=NULL;
newn->prev=NULL;
head=newn;
}
else
{
newn->next=head;
head->prev=newn;
head=newn;
newn->prev=NULL;
}
break;

case 2:
if(head->next==NULL)
{
printf("Single node entry so insertion is not allowed in the middle\n");
}
else
{
printf("Enter the data after which the element to be inserted:\t");
scanf("%d",&no);
temp=head;
while(temp->data!=no)
{
temp=temp->next;
}
newn->next=temp->next;
temp->next->prev=newn;
temp->next=newn;
newn->prev=temp;
}
break;

case 3:
if(head==NULL)
{
newn->next=NULL;
newn->prev=NULL;
head=newn;
}
else
{
temp=head;
while(temp->next!=NULL)
{
temp=temp->next;
}
temp->next=newn;
newn->prev=temp;
newn->next=NULL;
}
break;
}
}
void del()
{
int op,no;
if(head==NULL)
{
printf("List is empty\n");
}
else
{
printf("1.Deletion at first\n2.Deletion at middle\n3.Deletion at last\n");
printf("Enter your choice:\t");
scanf("%d",&op);
switch(op)
{
case 1:
if(head->next==NULL)
{
printf("The deleted element is: %d",head->data);
head=NULL;
}
else
{
temp=head;
head=head->next;
printf("The deleted element is: %d",temp->data);
free(temp);
}
break;

case 2:
if(head->next==NULL)
{
printf("Single node entry cannot perform deletion in the middle\n");
}
else
{
printf("Enter the element to be deleted:\t");
scanf("%d",&no);
temp=head;
while(temp->data!=no)
{
t=temp;
temp=temp->next;
}
temp->prev=t;
printf("The deleted element is: %d",temp->data);
t->next=temp->next;
temp->next->prev=t;
free(temp);
}
break;

case 3:
if(head->next==NULL)
{
printf("The deleted element is: %d",head->data);
head=NULL;
}
else
{
temp=head;
while(temp->next!=NULL)
{
t=temp;
temp=temp->next;
}
t->next=NULL;
printf("The deleted element is: %d",temp->data);
free(temp);
}
break;
}
}
}
void display()
{
if(head==NULL)
{
printf("List is empty\n");
}
else
{
temp=head;
printf("The elements in a list are:\n");
while(temp!=NULL)
{
printf("%d\n",temp->data);
temp=temp->next;
}
}

}


OUTPUT:

$$$ DOUBLY LINKED LIST $$$

DOUBLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        1
Enter the element to be inserted:       11
1.Insert at First
2.Insert at Middle
3.Insert at Last
Enter the option:       1

DOUBLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        1
Enter the element to be inserted:       33
1.Insert at First
2.Insert at Middle
3.Insert at Last
Enter the option:       3

DOUBLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        1
Enter the element to be inserted:       22
1.Insert at First
2.Insert at Middle
3.Insert at Last
Enter the option:       2
Enter the data after which the element to be inserted:  11

DOUBLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        3
The elements in a list are:
11
22
33

DOUBLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        2
1.Deletion at first
2.Deletion at middle
3.Deletion at last
Enter your choice:      2
Enter the element to be deleted:        22
The deleted element is: 22

DOUBLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        3
The elements in a list are:
11
33

DOUBLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        4

Singly Linked List

PROGRAM:

#include<stdio.h>
#include<conio.h>
#include<malloc.h>
typedef struct node
{
int data;
struct node *next;
}node;
node *head=NULL,*newn,*temp,*t;
void insert();
void del();
void display();
void main()
{
int ch;
clrscr();
printf("\n\n$$$ SINGLY LINKED LIST $$$\n\n");
while(1)
{
printf("\n\nSINGLY LINKED LIST OPERATIONS ARE\n\n");
printf("1.Insert\n2.Delete\n3.Display\n4.Exit\n");
printf("Enter Ur Choice:\t");
scanf("%d",&ch);
switch(ch)
{
case 1:insert();break;
case 2:del();break;
case 3:display();break;
case 4:exit(0);
default:printf("Enter the correct option\n");
break;
}
}
}
void insert()
{
int no,op;
newn=(node *)malloc(sizeof(node));
printf("Enter the element to be inserted:\t");
scanf("%d",&newn->data);
printf("1.Insert at First\n2.Insert at Middle\n3.Insert at Last\n");
printf("Enter the option:\t");
scanf("%d",&op);
switch(op)
{
case 1:
if(head==NULL)
{
head=newn;
head->next=NULL;
}
else
{
newn->next=head;
head=newn;
}
break;

case 2:
if(head->next==NULL)
{
printf("Single node entry so insertion is not allowed in the middle\n");
}
else
{
printf("Enter the data after which the element to be inserted:\t");
scanf("%d",&no);
temp=head;
while(temp->data!=no)
{
temp=temp->next;
}
newn->next=temp->next;
temp->next=newn;
}
break;

case 3:
temp=head;
if(head==NULL)
{
head=newn;
newn->next=NULL;
}
else
{
while(temp->next!=NULL)
{
temp=temp->next;
}
temp->next=newn;
newn->next=NULL;
}
break;
}
}
void del()
{
int op,no;
if(head==NULL)
{
printf("List is empty\n");
}
else
{
printf("1.Deletion at first\n2.Deletion at middle\n3.Deletion at last\n");
printf("Enter your choice:\t");
scanf("%d",&op);
switch(op)
{
case 1:
if(head->next==NULL)
{
printf("The deleted element is: %d",head->data);
head=NULL;
}
else
{
temp=head;
head=head->next;
printf("The deleted element is: %d",temp->data);
free(temp);
}
break;

case 2:
if(head->next==NULL)
{
printf("Single node entry cannot perform deletion in the middle\n");
}
else
{
printf("Enter the element to be deleted:\t");
scanf("%d",&no);
temp=head;
while(temp->data!=no)
{
t=temp;
temp=temp->next;
}
printf("The deleted element is: %d",temp->data);
t->next=temp->next;
}
break;

case 3:
temp=head;
if(head->next==NULL)
{
printf("The deleted element is: %d",head->data);
head=NULL;
}
else
{
while(temp->next!=NULL)
{
t=temp;
temp=temp->next;
}
t->next=NULL;
printf("The deleted element is: %d",temp->data);
}
break;
}
}
}
void display()
{
if(head==NULL)
{
printf("List is empty\n");
}
else
{
temp=head;
printf("The elements in a list are:\n");
while(temp!=NULL)
{
printf("%d\n",temp->data);
temp=temp->next;
}
}

}



OUTPUT:

$$$ SINGLY LINKED LIST $$$

SINGLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        1
Enter the element to be inserted:       11
1.Insert at First
2.Insert at Middle
3.Insert at Last
Enter the option:       1

SINGLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        1
Enter the element to be inserted:       33
1.Insert at First
2.Insert at Middle
3.Insert at Last
Enter the option:       3

SINGLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        1
Enter the element to be inserted:       22
1.Insert at First
2.Insert at Middle
3.Insert at Last
Enter the option:       2
Enter the data after which the element to be inserted:  11

SINGLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        3
The elements in a list are:
11
22
33

SINGLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        2
1.Deletion at first
2.Deletion at middle
3.Deletion at last
Enter your choice:      2
Enter the element to be deleted:        22
The deleted element is: 22

SINGLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:        3
The elements in a list are:
11
33

SINGLY LINKED LIST OPERATIONS ARE

1.Insert
2.Delete
3.Display
4.Exit
Enter Ur Choice:       4

Queue Implementation Using Linked List or Pointer

PROGRAM:


#include<stdio.h>
#include<conio.h>
typedef struct queue
{
                int data;
                struct queue *next;
}node;
node *newn,*front,*rear,*temp;
void enqueue();
void dequeue();
void display();
void main()
{
                int ch;
                clrscr();
                printf("\n\n\n$$$ QUEUE IMPLEMENTATION USING LINKED LIST OR POINTER $$$\n\n\n");
                while(1)
                {
                                printf("QUEUE OPERATIONS ARE\n");
                                printf("1.ENQUEUE\n2.DEQUEUE\n3.DISPLAY\n4.EXIT\n");
                                printf("Enter your choice:\t");
                                scanf("%d",&ch);
                                switch(ch)
                                {
                                                case 1:enqueue();break;
                                                case 2:dequeue();break;
                                                case 3:display();break;
                                                case 4:exit(0);
                                                default:printf("Enter the correct option\n");
                                                break;
                                }
                }
}
void enqueue()
{
                newn=(node *)malloc(sizeof(node));
                printf("Enter the element to be inserted:\t");
                scanf("%d",&newn->data);
                newn->next=NULL;
                if(front==NULL)
                {
                                front=newn;
                                rear=newn;
                }
                else
                {
                                rear->next=newn;
                                rear=newn;
                }
}
void dequeue()
{
                if(front==NULL)
                {
                                printf("Queue is empty or underflow\n");
                }
                else
                {
                                temp=front;
                                front=front->next;
                                printf("The deleted element is: %d",temp->data);
                }
                free(temp);
}
void display()
{
                if(front==NULL)
                {
                                printf("Queue is empty or underflow\n");
                }
                else
                {
                                temp=front;
                                printf("Content of the queue is:\n");
                                while(temp!=NULL)
                                {
                                                printf("%d\n",temp->data);
                                                temp=temp->next;
                                }
                }
}


 OUTPUT:

$$$ QUEUE IMPLEMENTATION USING LINKED LIST OR POINTER $$$

 QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT
Enter your choice:      1
Enter the element to be inserted:       11

QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT
Enter your choice:      1
Enter the element to be inserted:       22

QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT
Enter your choice:      1
Enter the element to be inserted:       33

QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT
Enter your choice:      3
Content of the queue is:
11
22
33

QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT
Enter your choice:      2
The deleted element is: 11

QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT
Enter your choice:           3
Content of the queue is:
22
33

QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT

Enter your choice:      4

Queue Implementation Using Array

PROGRAM:


#include<stdio.h>
#include<conio.h>
#define SIZE 5
void enqueue();
void dequeue();
void display();
int q[SIZE],i,item,front=-1,rear=-1;
void main()
{
                int ch;
                clrscr();
                printf("\n\n\n$$$ QUEUE IMPLEMENTATION USING ARRAY $$$\n\n\n");
                while(1)
                {
                                printf("QUEUE OPERATIONS ARE\n");
                                printf("1.ENQUEUE\n2.DEQUEUE\n3.DISPLAY\n4.EXIT\n");
                                printf("Enter your choice:\t");
                                scanf("%d",&ch);
                                switch(ch)
                                {
                                                case 1:enqueue();break;
                                                case 2:dequeue();break;
                                                case 3:display();break;
                                                case 4:exit(0);
                                                default:printf("Enter the correct option\n");
                                                break;
                                }
                }
}
void enqueue()
{
                if(rear==SIZE-1)
                {
                                printf("Queue is full or overflow\n");
                }
                else
                {
                               if(front==-1)
                               {
                                           front=0;
                                }
                                printf("Enter the element to be enqueued:\t");
                                scanf("%d",&item);
                                rear=rear+1;
                                q[rear]=item;
                }
}
void dequeue()
{
                if(front==-1 || front>rear)
                {
                                printf("Queue is empty or underflow\n");
                }
                else
                {
                                printf("The deleted element is: %d",q[front]);
                                front=front+1;
                }
}
void display()
{
                if(front==-1 || front>rear)
                {
                                printf("Queue is empty or underflow\n");
                }
                else
                {
                                printf("Content of the queue is:\n");
                                for(i=front;i<=rear;i++)
                                {
                                                printf("%d\n",q[i]);
                                }
                }
}



 OUTPUT:

$$$ QUEUE IMPLEMENTATION USING ARRAY $$$

 QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT
Enter your choice:      1
Enter the element to be enqueued:       11

QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT
Enter your choice:      1
Enter the element to be enqueued:       22

QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT
Enter your choice:      1
Enter the element to be enqueued:       33

QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT
Enter your choice:      3
Content of the queue is:
11
22
33

QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT
Enter your choice:      2
The deleted element is: 11

QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT
Enter your choice:3
Content of the queue is:
22
33

QUEUE OPERATIONS ARE
1.ENQUEUE
2.DEQUEUE
3.DISPLAY
4.EXIT

Enter your choice:      4

Saturday, 12 April 2014

Balancing Symbol

PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
                int top=-1,d=0;
                char ch,stack[30];
                clrscr();
                printf("\n\n$$$ BALANCING SYMBOLS $$$\n\n");
                printf("Check whether the given expression is balanced or not\n");
                printf("Enter the expression:\t");
                while(ch=getchar(),ch!='#')
                {
                                switch(ch)
                                {
                                                case '(':stack[++top]=ch;break;
                                                case '{':stack[++top]=ch;break;
                                                case '[':stack[++top]=ch;break;
                                                case ')':if(stack[top]=='(')
                                                                 {
                                                                                top=top-1;
                                                                 }
                                                                 else
                                                                 {
                                                                                d=d+1;
                                                                 }
                                                                 break;
                                                case '}':if(stack[top]=='{')
                                                                 {
                                                                                top=top-1;
                                                                 }
                                                                 else
                                                                 {
                                                                                d=d+1;
                                                                 }
                                                                 break;
                                                case ']':if(stack[top]=='[')
                                                                 {
                                                                                top=top-1;
                                                                 }
                                                                 else
                                                                 {
                                                                                d=d+1;
                                                                 }
                                                                 break;
                                }
                }
                if(top==-1 && d==0)
                {
                                printf("Balanced Expression\n");
                }
                else
                {
                                printf("Unbalanced Expression\n");
                }
                getch();
}

OUTPUT:
$$$ BALANCING SYMBOLS $$$

Check whether the given expression is balanced or not
Enter the expression:   {[(a+b)*c]-[(c*d)+b]}#
Balanced Expression


$$$ BALANCING SYMBOLS $$$

Check whether the given expression is balanced or not
Enter the expression:   {(a*b]/(c+d]}#

Unbalanced Expression

Infix to Postfix Conversion

PROGRAM:
#include<stdio.h>
#include<conio.h>
#define SIZE 50
void push(char);
char pop();
int priority(char);
char s[SIZE];
int top=-1;
void main()
{
                char infix[50],postfix[50],ch,item;
                int i=0,k=0,len;
                clrscr();
                printf("\n\n $$$ INFIX TO POSTFIX CONVERSION $$$ \n\n");
                printf("Enter infix expression:\t");
                scanf("%s",infix);
                push('#');
                len=strlen(infix);
                for(i=0;i<len;i++)
                {
                                ch=infix[i];
                                if(isalnum(ch))
                                {
                                                postfix[k]=ch;
                                                k++;
                                }
                                else if(ch=='(')
                                {
                                                push(ch);
                                }
                                else if(ch==')')
                                {
                                                while(s[top]!='(')
                                                {
                                                                postfix[k]=pop();
                                                                k++;
                                                }
                                                item=pop();
                                }
                                else
                                {
                                                while(priority(s[top])>=priority(ch))
                                                {
                                                                postfix[k]=pop();
                                                                k++;
                                                }
                                                push(ch);
                                }
                }
                while(s[top]!='#')
                {
                                postfix[k]=pop();
                                k++;
                }
                postfix[k]='\0';
                printf("Postfix expression is: %s",postfix);
                getch();
}
void push(char a)
{
                top=top+1;
                s[top]=a;
}
char pop()
{
                char a;
                a=s[top];
                top=top-1;
                return a;
}
int priority(char a)
{
                switch(a)
                {
                                case '#':return 0;
                                case '(':return 1;
                                case '+':return 2;
                                case '-':return 2;
                                case '*':return 3;
                                case '/':return 3;
                                case '^':return 4;
                }
}

OUTPUT:
$$$ INFIX TO POSTFIX CONVERSION $$$
Enter infix expression: (A+B^C)*D+E^5

Postfix expression is: ABC^+D*E5^+