Yacc Program To Convert Infix To Postfix Expression

Program to convert infix expression to postfix expression (DS Lab).
infixtopostfix.c
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#defineSIZE30
voidpush(char);
charpop();
intpreced(char);
char stack[SIZE], postfix[SIZE], infix[SIZE];
int top = -1;
intmain()
{
char ch;
int i, k, p = 0;
for(i=0; i<SIZE; i++)
{
stack[i] = '0';
}
printf('nEnter an infix expression: ');
scanf('%s',infix);
for(i=0; infix[i] != '0'; i++)
{
ch = infix[i];
if (isalnum(ch))
{
postfix[p++] = ch;
}
elseif (ch '(')
{
push(ch);
}
elseif (ch ')')
{
while(stack[top] != '(')
{
postfix[p++] = pop();
}
pop();
}
elseif (ch '/' ch '*' ch '+' ch '-')
{
if (preced(ch) > preced(stack[top]))
{
push(ch);
}
else
{
while (preced(ch) <= preced(stack[top]))
{
postfix[p++] = pop();
}
}
}
}
postfix[p] = '0';
while(top > -1)
postfix[p++] = pop();
printf('nThe postfix expression is: %sn',postfix);
return0;
}
voidpush(char el)
{
if (top < SIZE-1)
{
stack[++top] = el;
}
else
{
printf('nError! Stack is full.n');
exit(-1);
}
}
charpop()
{
char ch;
if (top > -1)
{
ch = stack[top];
stack[top--] = '0';
return ch;
}
else
{
printf('nError! Stack is empty.n');
exit(-1);
}
}
intpreced(char ch)
{
if(ch '(' ch ')')
return0;
elseif (ch '+' ch '-')
return1;
elseif (ch '/' ch '*')
return2;
}

commented Aug 7, 2018

Wrong Program !!!!
correct it please..

Create video from image and audio files. Create video files from single image and audio file in.Size: 13.5 MB License: Shareware Price: $49.99 Keywords: -Data Added 1: June 02, 2015The Gitashare Clean Master Pro That Is The Best System Care. Protects you against viruses, spyware, hackers, phishing, botnets and more; Protects your identity when you shop and bank online; Boosts, cleans, and fixes all kinds of PC problems with just 1 click;Size: 830.1 KB License: Freeware Keywords: -Data Added 1: September 12, 2012FS master is the optimum software for data and text security. Not only cleaning up junk files, temporary files, malware, and invalid registry entries, but by giving your computer a boost to optimize your PC experience. Olympus camedia master software download.

Serial keygens cracks. I have been trying to convert an infix expression to postfix expression using YACC(Bison) with no success. I would like to know how it can be done? Sample code will be awesome:).

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment