DSA Lab Program - 4
DSA Lab Program - 4
Algorithm:
Step 1: Start.
Step 4: Stop
Program:-
#include <ctype.h>
#include <stdio.h>
char s[SIZE];
s[++top] = elem;
return (s[top--]);
1
Program 4
switch (elem)
case '#':
return 0;
case '(':
return 1;
case '+':
case '-':
return 2;
case '*':
case '/':
case '%':
return 3;
case '^':
return 4;
int i = 0, k = 0;
2
Program 4
scanf("%s", infx);
push('#');
if (ch == '(')
push(ch);
else if (isalnum(ch))
pofx[k++] = ch;
pofx[k++] = pop();
else /* Operator */
pofx[k++] = pop();
push(ch);
pofx[k++] = pop();
3
Program 4
Output 1:
Output 2: