0
2.2kviews
Write a C program that use stack operations to convert infix expression to postfix expression.

Test the program for the following Infix Expressions:

1] A + B

2] A + B * C - D

1 Answer
0
182views

Infix to Postfix Conversion using the Stack Operations

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
char pop();
void push(char);
int pri(char);
char st[10];
int top=-1;
void main()
{
char s[25];
int i;
printf("Enter Infix Expression: ");
gets(s);
push('(');
strcat(s,")");
for(i=0;i<s[i];i++)
{
if(isalnum(s[i]))
printf("%c",s[i]);
else if(s[i]=='(')
push(s[i]);
else if(s[i]==')')
{
 while(st[top]!='(')
 printf("%c",pop());
 pop();
 } …

Create a free account to keep reading this post.

and 4 others joined a min ago.

Please log in to add an answer.