<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>infix to postfix | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/infix-to-postfix/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Sat, 09 Jun 2012 16:24:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>C Program for Infix to Postfix Conversion</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-infix-to-postfix-conversion/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-infix-to-postfix-conversion/#comments</comments>
		
		<dc:creator><![CDATA[Ansten Lobo]]></dc:creator>
		<pubDate>Sat, 09 Jun 2012 16:24:25 +0000</pubDate>
				<category><![CDATA[Data Structures]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[infix to postfix]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=3299</guid>

					<description><![CDATA[<p>Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT #define SIZE 50 /* Size of Stack */ #include char s[SIZE]; int top=-1; /* Global declarations */ push(char elem) { /* Function for PUSH operation */ s[++top]=elem; } char pop() { /* Function for POP operation */ return(s[top--]); } int pr(char elem) {</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-infix-to-postfix-conversion/">C Program for Infix to Postfix Conversion</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Source: Dr. G T Raju, Professor &#038; Head, Dept. of CSE, RNSIT</p>
<pre lang="C" line="1">
#define SIZE 50            /* Size of Stack */
#include <ctype.h>
char s[SIZE];
int top=-1;       /* Global declarations */

push(char elem)
{                       /* Function for PUSH operation */
    s[++top]=elem;
}

char pop()
{                      /* Function for POP operation */
    return(s[top--]);
}

int pr(char elem)
{                 /* Function for precedence */
    switch(elem)
    {
    case '#': return 0;
    case '(': return 1;
    case '+':
    case '-': return 2;
    case '*':
    case '/': return 3;
    }
}

main()
{                         /* Main Program */
    char infx[50],pofx[50],ch,elem;
    int i=0,k=0;
    printf("\n\nRead the Infix Expression ? ");
    scanf("%s",infx);
    push('#');
    while( (ch=infx[i++]) != '\0')
    {
        if( ch == '(') push(ch);
        else
            if(isalnum(ch)) pofx[k++]=ch;
            else
                if( ch == ')')
                {
                    while( s[top] != '(')
                        pofx[k++]=pop();
                    elem=pop(); /* Remove ( */
                }
                else
                {       /* Operator */
                    while( pr(s[top]) >= pr(ch) )
                        pofx[k++]=pop();
                    push(ch);
                }
    }
    while( s[top] != '#')     /* Pop from stack till empty */
        pofx[k++]=pop();
    pofx[k]='\0';          /* Make pofx as valid string */
    printf("\n\nGiven Infix Expn: %s  Postfix Expn: %s\n",infx,pofx);
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-infix-to-postfix-conversion/">C Program for Infix to Postfix Conversion</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/data-structures-c/c-program-for-infix-to-postfix-conversion/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program to convert an Expression from Infix expression to Prefix form</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-convert-an-expression-from-infix-expression-to-prefix-form/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-convert-an-expression-from-infix-expression-to-prefix-form/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Mon, 31 Jan 2011 11:55:00 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[infix]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[infix to postfix]]></category>
		<category><![CDATA[push]]></category>
		<category><![CDATA[pop]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1257</guid>

					<description><![CDATA[<p>#include #include #include const int MAX = 50 ; class infix { private : char target[MAX], stack[MAX] ; char *s, *t ; int top, l ; public : infix( ) ; void setexpr ( char *str ) ; void push ( char c ) ; char pop( ) ; void convert( ) ; int priority</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-convert-an-expression-from-infix-expression-to-prefix-form/">C++ program to convert an Expression from Infix expression to Prefix form</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#include <iostream.h>
#include <string.h>
#include <ctype.h>
const int MAX = 50 ;
class infix
{
	private :
		char target[MAX], stack[MAX] ;
		char *s, *t ;
		int top, l ;
	public :
		infix( ) ;
		void setexpr ( char *str ) ;
		void push ( char c ) ;
		char pop( ) ;
		void convert( ) ;
		int priority ( char c ) ;
		void show( ) ;
} ;
infix :: infix( )
{
	top = -1 ;
	strcpy ( target, "" ) ;
	strcpy ( stack, "" ) ;
	l = 0 ;
}
void infix :: setexpr ( char *str )
{
	s = str ;
	strrev ( s ) ;
	l = strlen ( s ) ;
	* ( target + l ) = '\0' ;
	t = target + ( l - 1 ) ;
}
void infix :: push ( char c )
{
	if ( top == MAX - 1 )
		cout << "\nStack is full\n" ;
	else
	{
		top++ ;
		stack[top] = c ;
	}
}
char infix :: pop( )
{
	if ( top == -1 )
	{
		cout << "Stack is empty\n" ;
		return -1 ;
	}
	else
	{
		char item = stack[top] ;
		top-- ;
		return item ;
	}
}
void infix :: convert( )
{
	char opr ;

	while ( *s )
	{
		if ( *s == ' ' || *s == '\t' )
		{
			s++ ;
			continue ;
		}

		if ( isdigit ( *s ) || isalpha ( *s ) )
		{
			while ( isdigit ( *s ) || isalpha ( *s ) )
			{
				*t = *s ;
				s++ ;
				t-- ;
			}
		}

		if ( *s == ')' )
		{
			push ( *s ) ;
			s++ ;
		}

		if ( *s == '*' || *s == '+' || *s == '/' ||
				*s == '%' || *s == '-' || *s == '$' )
		{
			if ( top != -1 )
			{
				opr = pop( ) ;

				while ( priority ( opr ) > priority ( *s ) )
				{
					*t = opr ;
					t-- ;
					opr = pop( ) ;
				}
				push ( opr ) ;
				push ( *s ) ;
			}
			else
				push ( *s ) ;
			s++ ;
		}

		if ( *s == '(' )
		{
			opr = pop( ) ;
			while ( ( opr ) != ')' )
			{
				*t = opr ;
				t-- ;
				opr =  pop ( ) ;
			}
			s++ ;
		}
	}

	while ( top != -1 )
	{
		opr = pop( ) ;
		*t = opr ;
		t-- ;
	}
	t++ ;
}
int infix :: priority ( char c )
{
	if ( c == '$' )
		return 3 ;
	if ( c == '*' || c == '/' || c == '%' )
		return 2 ;
	else
	{
		if ( c == '+' || c == '-' )
			return 1 ;
		else
			return 0 ;
	}
}
void infix :: show( )
{
	while ( *t )
	{
		cout << " " << *t ;
		t++ ;
	}
}

void main( )
{
	char expr[MAX] ;
	infix q ;

	cout << "\nEnter an expression in infix form: " ;
	cin.getline ( expr, MAX ) ;

	q.setexpr( expr ) ;
	q.convert( ) ;

	cout << "The Prefix expression is: " ;
	q.show( ) ;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-convert-an-expression-from-infix-expression-to-prefix-form/">C++ program to convert an Expression from Infix expression to Prefix form</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-convert-an-expression-from-infix-expression-to-prefix-form/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>Java program that converts infix expression into postfix form</title>
		<link>https://studentprojects.in/software-development/java/java-programs/advanced/java-program-that-converts-infix-expression-into-postfix-form/</link>
					<comments>https://studentprojects.in/software-development/java/java-programs/advanced/java-program-that-converts-infix-expression-into-postfix-form/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Sun, 04 Oct 2009 14:24:30 +0000</pubDate>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[infix]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[infix to postfix]]></category>
		<category><![CDATA[postfix convertor]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=876</guid>

					<description><![CDATA[<p>Enter input string<br />
a+b*c<br />
Input String:a+b*c<br />
Output String:<br />
abc*+</p>
<p>The post <a href="https://studentprojects.in/software-development/java/java-programs/advanced/java-program-that-converts-infix-expression-into-postfix-form/">Java program that converts infix expression into postfix form</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="java" escaped="true" line="1">
import java.io.*;
class stack
{
	char stack1[]=new char[20];
	int top;
	void push(char ch)
	{
		top++;
		stack1[top]=ch;
	}
	char pop()
	{
		char ch;
		ch=stack1[top];
		top--;
		return ch;
	}
	int pre(char ch)
	{
		switch(ch)
		{
			case '-':return 1;
			case '+':return 1;
			case '*':return 2;
			case '/':return 2;
		}
		return 0;
	}
	boolean operator(char ch)
	{
		if(ch=='/'||ch=='*'||ch=='+'||ch=='-')
			return true;
		else
			return false;
	}
	boolean isAlpha(char ch)
	{
		if(ch>='a'&&ch<='z'||ch>='0'&&ch=='9')
			return true;
		else
			return false;
	}
	void postfix(String str)
	{
		char output[]=new char[str.length()];
		char ch;
		int p=0,i;
		for(i=0;i<str.length();i++)
		{
			ch=str.charAt(i);	
			if(ch=='(')
			{
				push(ch);
			}
			else if(isAlpha(ch))
			{
				output[p++]=ch;
			}
			else if(operator(ch))
			{
				if(stack1[top]==0||(pre(ch)>pre(stack1[top]))||stack1[top]=='(')
			{
				push(ch);
			}
			}
			else if(pre(ch)<=pre(stack1[top]))
			{
				output[p++]=pop();
				push(ch);
			}
			else if(ch=='(')
			{
				while((ch=pop())!='(')
				{
					output[p++]=ch;
				}
			}
		}
		while(top!=0)
		{
			output[p++]=pop();
		}
		for(int j=0;j<str.length();j++)
		{
			System.out.print(output[j]);	
		}
	}
}
class intopost
{
	public static void main(String[] args)throws Exception
	{
		String s;
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		stack b=new stack();
		System.out.println("Enter input string");
		s=br.readLine();
		System.out.println("Input String:"+s);
		System.out.println("Output String:");
		b.postfix(s);
	}
}			
</pre>
<p><strong>Output:</strong></p>
<p>Enter input string<br />
a+b*c<br />
Input String:a+b*c<br />
Output String:<br />
abc*+</p>
<p>Enter input string<br />
a+(b*c)/d<br />
Input String:a+(b*c)/d<br />
Output String:<br />
abc*d/)(+</p><p>The post <a href="https://studentprojects.in/software-development/java/java-programs/advanced/java-program-that-converts-infix-expression-into-postfix-form/">Java program that converts infix expression into postfix form</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/java/java-programs/advanced/java-program-that-converts-infix-expression-into-postfix-form/feed/</wfw:commentRss>
			<slash:comments>11</slash:comments>
		
		
			</item>
	</channel>
</rss>
