I know it sounds weird but when i uncomment statements in the following ,it works perfectly fine for infix to postfix conversion.although comments are simple cout statements,,execution with cout statements as comments breaks in b/w.
I have found this particularly with a^b-c.
DevCPP is also showing similar behavior.
I can't understand what's going on.I am working on code blocks. Please help!!
#include<iostream>
#include<cstdio>
#include<conio.h>
using namespace std;
char stk[15];
int top=-1;
void push(char c)
{
top++;
stk[top]=c;
}
char pop()
{
char c=stk[top];
top--;
return c;
}
int prec(char a)
{
switch(a)
{
case '^':
return 5;
break;
case '/':
return 4;
break;
case '*':
return 3;
break;
case '+':
return 2;
break;
case '-':
return 1;
}
}
Thanx..
The program is doing "infix to postfix" conversion.
I am really not able to find either syntactical or logical error in the code you have asked to do so.
["code"]
#define NULL 0
["\code"]
is not helping. And moreover i have been using NULL since long as a keyword.
It is really a confusion how the code works correct by some cout statements as you see uncommenting the comments in the above code makes it work well,specifically for a^b-c as input.
please help!!!