Professional Documents
Culture Documents
h>
#define size 50
int top=-1;
int a[size];
void push();
int pop();
int main()
{
char infix[50],ch;
int i=0,flag=0;
else
{
printf("Unbalanced exp");
flag=1;
break;
}
}
else if (ch == ']' )
{
if( a[top] == '[' )
pop();
else
{
printf("Unbalanced exp");
flag=1;
break;
}
}
else if (ch == '}' )
{
if( a[top]== '{' )
pop();
else
{
printf("Unbalanced exp");
flag=1;
break;
}
}
}
if( top == -1 && flag==0 )
printf("Exp is balanced");
else
printf("Exp is not balanced");
}