Posts

Queue program #1

Image
21. Implement Simple Queue using array that performs following operations: INSERT, DELETE, DISPLAY. #include<stdio.h> #define N 50 int q[N]; int f=-1; int r=-1; void enqueue(int y); int dequeue(); void display(); void main() {      int ch,x,a;     printf ("QUEUE OPERATION\n");     while (1)     {         printf ("------------------------------------------\n");         printf ("      1    -->    INSERT               \n");         printf ("      2    -->    DELETE               \n");         pr...

Stack Program #6

Image
20. Write a program for evaluation of pre-fix expression using Stack. #include<stdio.h> #include<string.h> #define N 50 char s[N]; int top=-1; void push(int); int pop(); int perform(int oprand1,int oprand2,char temp); void main() {      int i=0,value=0,oprand1,oprand2,x,result,l=0;      char prefix[50],temp;      printf("Enter the prefix expression:\n");      scanf("%s",prefix);      l=strlen(prefix);      i=l-1;      temp=prefix[i];      while(i>=0)      {      if(temp>='0' && temp<='9')      {           push(temp-'0');      }      else      {           oprand1...

Stack Program #5

Image
19. Write a program for evaluation of post-fix expression using Stack. #include<stdio.h> #define N 50 char s[N]; int top=-1; void push(int); int pop(); int perform(int oprand1,int oprand2,char temp); void main() {      int i=0,value=0,oprand1,oprand2,x,result,j;      char postfix[50],temp;      printf("Enter the postfix expression:\n");      scanf("%s",postfix);      temp=postfix[i];      while(temp!='\0')      {      if(temp>='0' && temp<='9')      {           push(temp-'0');      }      else      {           oprand2=pop();           oprand1=pop();    ...

Stack Program #4

Image
18. Write a program to convert in-fix notation to pre-fix notation using Stack. #include<stdio.h> #include<string.h> #define N 50 char s[N]; int top=-1; void push(char); char pop(); int f(char); int g(char); int r(char); void main() {      int i=0,k=0,j=0,rank,c=0,l=0,a=0,m=0;      char infix1[50],infix[50],next,temp,x,polish[50],polish1[50];      printf("Enter a infix expression with extra closing bracket:\n");      scanf("%s",infix1);      while(infix1[k]!='\0')      {           l++; // size getting           k++; //string increase      }      for(j=l-1;j>=0;j--)      {            infix[i]=infix1[j];     ...

Stack Program #3

Image
17. Write a program to convert in-fix notation to post-fix notation using Stack. #include<stdio.h> #define N 50 char s[N]; int top=-1; void push(char); char pop(); int f(char); int g(char); int r(char); void main() {      int i=0,j=0,rank;      char infix[50],next,temp,x,polish[50];      top=0;      s[top]='(';      polish[50]='\0';      rank=0;      printf(" Enter a infix expression with extra closing bracket :\n");      scanf("%s",infix);      next=infix[i];      while(next!='\0')      {           if(top<0)           {                printf("Invalid\n");                return;           }           while(g(...