C program to convert infix notation to postfix notation

Posted: April 1, 2012 in Lab 7
/* c prog for infix to postfix conversion
 written by- Shivam Rana */
#include<stdio.h>
#include<string.h>
int main()
{
int i,j,l,m;
char a[400],b[400];
m=-1;
scanf("%s",&a);
l=strlen(a);
for(j=0;j<l;j++)
{
if(a[j]=='(')
continue;
else if(a[j]>64 && a[j]<91 ||a[j]>96 && a[j]<123)
printf("%c",a[j]);
else if(a[j]==')')
{
printf("%c",b[m]);
m--;
}
else
{
m++;
b[m]=a[j];
}
}printf("\n");

return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s