{"id":10586,"date":"2022-11-18T09:46:50","date_gmt":"2022-11-18T09:46:50","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=10586"},"modified":"2023-04-12T06:05:54","modified_gmt":"2023-04-12T06:05:54","slug":"c-program-to-convert-infix-to-postfix","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/","title":{"rendered":"C Program to Convert Infix to Postfix"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668833413965-C%20Program%20to%20Convert%20Infix%20to%20Postfix.jpg\" alt=\"\" \/><\/p>\n<p>In computer science, infix notation is a common way of representing mathematical expressions where operators are placed between operands. However, when it comes to evaluating expressions, postfix notation (also known as Reverse Polish Notation) can be more convenient and efficient. In postfix notation, operators come after the operands they act on. For example, the infix expression &quot;3 + 4&quot; would be written as &quot;3 4 +&quot; in postfix notation. Here we will discuss, how to convert infix to postfix programs in C language, an algorithm to convert infix to postfix programs in C, and some methods or approaches to convert infix to postfix programs in C language.<\/p>\n<ul>\n<li><strong>Infix<\/strong> \u2013 Any operation of format x op y format example x + y is called an infix operation<\/li>\n<li><strong>Postfix<\/strong> \u2013 An operation or expression can also be written in the format of x y op i.e. x y + which is similar to writing x + y in infix. All we are doing is shifting the operator to the right of the operand.<\/li>\n<\/ul>\n<h2>Algorithm to Convert Infix to Postfix Program in C<\/h2>\n<ul>\n<li>Start scanning the given expression from left to right.<\/li>\n<li>If the scanned character is an operand, just print it.<\/li>\n<li>Else\n<ul>\n<li>If the precedence of the operand is higher than the precedence of the operator the stack(or stack is empty or has'(\u2018), then push the operator in the stack.<\/li>\n<li>Else, Pop all the operators, that have greater or equal precedence than the scanned operator. Once you pop them push this scanned operator. (If we see a parenthesis while popping then stop and push the scanned operator in the stack)<\/li>\n<\/ul>\n<\/li>\n<li>If the scanned character is an \u2018(\u2018, push it to the stack.<\/li>\n<li>If the scanned character is an \u2018)\u2019, pop the stack and output it until a \u2018(\u2018 is encountered, and discard both the parenthesis.<\/li>\n<li>Now, we should repeat steps 2 \u2013 6 until the whole infix i.e. whole characters are scanned.<\/li>\n<li>Print output<\/li>\n<li>Do the pop and output (print) until the stack is not empty<\/li>\n<\/ul>\n<h2>Methods to Covert Infix to Postfix Program in C<\/h2>\n<p>Below are some methods with the help of an explanation:<\/p>\n<h3>Method 1: Array-based Stack Approach to Convert Infix to Postfix<\/h3>\n<p>In this method, we will implement an array-based stack approach.<\/p>\n<p><strong>Code Implementation of C Program to Convert Infix to Postfix<\/strong><\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_10608 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_10608 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_10608 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_10608 .wpsm_nav-tabs > li.active > a, #tab_container_10608 .wpsm_nav-tabs > li.active > a:hover, #tab_container_10608 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_10608 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_10608 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_10608 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_10608 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_10608 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_10608 .wpsm_nav-tabs > li > a:hover , #tab_container_10608 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_10608 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_10608 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_10608 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_10608 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_10608 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_10608 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_10608 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10608 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_10608 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10608 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_10608 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_10608\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_10608\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_10608_1\" aria-controls=\"tabs_desc_10608_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_10608\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_10608_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"c\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n#include &lt;limits.h&gt;\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n#define MAX 20\r\n\r\nchar stk[20];\r\nint top = -1;\r\n\r\nint isEmpty(){\r\n    return top == -1;\r\n}\r\nint isFull(){\r\n    return top == MAX - 1;\r\n}\r\n\r\nchar peek(){\r\n    return stk[top];\r\n}\r\n\r\nchar pop(){\r\n    if(isEmpty())\r\n        return -1;\r\n\r\n    char ch = stk[top];\r\n    top--;\r\n    return(ch);\r\n}\r\n\r\nvoid push(char oper){\r\n    if(isFull())\r\n        printf(&quot;Stack Full!!!!&quot;);\r\n   \r\n    else{\r\n        top++;\r\n        stk[top] = oper;\r\n    }\r\n}\r\n\r\nint checkIfOperand(char ch) \r\n{ \r\n    return (ch &gt;= 'a' &amp;&amp; ch &lt;= 'z') || (ch &gt;= 'A' &amp;&amp; ch &lt;= 'Z'); \r\n} \r\n\r\nint precedence(char ch) \r\n{ \r\n    switch (ch) \r\n    { \r\n    case '+': \r\n    case '-': \r\n        return 1; \r\n\r\n    case '*': \r\n    case '\/': \r\n        return 2; \r\n\r\n    case '^': \r\n        return 3; \r\n    } \r\n    return -1; \r\n} \r\n\r\nint covertInfixToPostfix(char* expression) \r\n{ \r\n    int i, j;\r\n\r\n    for (i = 0, j = -1; expression[i]; ++i) \r\n    { \r\n       if (checkIfOperand(expression[i])) \r\n            expression[++j] = expression[i]; \r\n\r\n        else if (expression[i] == '(') \r\n            push(expression[i]); \r\n\r\n        else if (expression[i] == ')') \r\n        { \r\n            while (!isEmpty() &amp;&amp; peek() != '(') \r\n                expression[++j] = pop(); \r\n            if (!isEmpty() &amp;&amp; peek() != '(') \r\n                return -1; \/\/ invalid expression              \r\n            else\r\n                pop(); \r\n        }\r\n        else \/\/ if an opertor\r\n        { \r\n            while (!isEmpty() &amp;&amp; precedence(expression[i]) &lt;= precedence(peek())) \r\n                expression[++j] = pop(); \r\n            push(expression[i]); \r\n        } \r\n\r\n    } \r\n\r\n    while (!isEmpty()) \r\n        expression[++j] = pop(); \r\n\r\n    expression[++j] = '&#92;0'; \r\n    printf( &quot;%s&quot;, expression); \r\n} \r\n\r\nint main()\r\n{\r\nchar expression[] = &quot;((p+(q*r))-s)&quot;; \r\n    covertInfixToPostfix(expression); \r\n    return 0; \r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_10608 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_10608 a\"),jQuery(\"#tab-content_10608\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Output:<\/strong><\/p>\n<pre><code>pqr*+s-<\/code><\/pre>\n<p><strong>Explanation<\/strong><br \/>\nThis code implements the algorithm to convert an infix expression to postfix in C language. It defines a Stack data structure and uses it to keep track of operators during the conversion process. The main function creates an infix expression and then passes it as an argument to the covertInfixToPostfix function. The covertInfixToPostfix function loops through the input infix expression character by character. If the character is an operand, it is added directly to the output postfix expression. If the character is an opening parenthesis, it is pushed onto the stack. If the character is a closing parenthesis, operators are popped from the stack and added to the output postfix expression until the corresponding opening parenthesis is reached.<\/p>\n<p>If the character is an operator, it is compared to the operator at the top of the stack. If the precedence of the current operator is lower than or equal to the top operator, the top operator is popped from the stack and added to the output postfix expression. This continues until the stack is empty or the precedence of the current operator is higher than the top operator. Finally, any remaining operators are popped from the stack and added to the output postfix expression. The function returns -1 if there is an error in the expression or if the stack was not created successfully.<\/p>\n<h3>Method 2: Struct-based Stack Approach to Convert Infix to Postfix<\/h3>\n<p>In this method, we will implement a struct-based stack approach.<\/p>\n<p><strong>Code Implementation  of C Program to Convert Infix to Postfix<\/strong><\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_10609 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_10609 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_10609 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_10609 .wpsm_nav-tabs > li.active > a, #tab_container_10609 .wpsm_nav-tabs > li.active > a:hover, #tab_container_10609 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_10609 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_10609 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_10609 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_10609 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_10609 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_10609 .wpsm_nav-tabs > li > a:hover , #tab_container_10609 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_10609 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_10609 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_10609 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_10609 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_10609 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_10609 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_10609 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10609 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_10609 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10609 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_10609 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_10609\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_10609\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_10609_1\" aria-controls=\"tabs_desc_10609_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_10609\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_10609_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"c\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n#include&lt;stdio.h&gt;\r\n#include &lt;string.h&gt;\r\n#include &lt;limits.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n\r\nstruct Stack { \r\n    int top; \r\n    int maxSize;\r\n    int* array; \r\n}; \r\n\r\nstruct Stack* create(int max) \r\n{ \r\n    struct Stack* stack = (struct Stack*)malloc(sizeof(struct Stack)); \r\n    stack-&gt;maxSize = max; \r\n    stack-&gt;top = -1; \r\n    stack-&gt;array = (int*)malloc(stack-&gt;maxSize * sizeof(int));\r\n    return stack; \r\n} \r\n\r\nint isFull(struct Stack* stack) \r\n{ \r\n    if(stack-&gt;top == stack-&gt;maxSize - 1){\r\n        printf(&quot;Will not be able to push maxSize reached&#92;n&quot;);\r\n    }\r\n    return stack-&gt;top == stack-&gt;maxSize - 1; \r\n} \r\n\r\nint isEmpty(struct Stack* stack) \r\n{ \r\n    return stack-&gt;top == -1; \r\n}\r\n\r\nvoid push(struct Stack* stack, int item) \r\n{ \r\n    if (isFull(stack)) \r\n        return; \r\n    stack-&gt;array[++stack-&gt;top] = item; \r\n}\r\n\r\nint pop(struct Stack* stack) \r\n{ \r\n    if (isEmpty(stack)) \r\n        return INT_MIN; \r\n    return stack-&gt;array[stack-&gt;top--]; \r\n} \r\n\r\nint peek(struct Stack* stack) \r\n{ \r\n    if (isEmpty(stack)) \r\n        return INT_MIN; \r\n    return stack-&gt;array[stack-&gt;top]; \r\n} \r\n\r\nint checkIfOperand(char ch) \r\n{ \r\n    return (ch &gt;= 'a' &amp;&amp; ch &lt;= 'z') || (ch &gt;= 'A' &amp;&amp; ch &lt;= 'Z'); \r\n} \r\nint precedence(char ch) \r\n{ \r\n    switch (ch) \r\n    { \r\n    case '+': \r\n    case '-': \r\n        return 1; \r\n\r\n    case '*': \r\n    case '\/': \r\n        return 2; \r\n\r\n    case '^': \r\n        return 3; \r\n    } \r\n    return -1; \r\n} \r\n\r\nint covertInfixToPostfix(char* expression) \r\n{ \r\n    int i, j; \r\n\r\n    struct Stack* stack = create(strlen(expression)); \r\n    if(!stack) \/\/ just checking is stack was created or not  \r\n        return -1 ; \r\n\r\n    for (i = 0, j = -1; expression[i]; ++i) \r\n    { \r\n       if (checkIfOperand(expression[i])) \r\n            expression[++j] = expression[i]; \r\n\r\n         else if (expression[i] == '(') \r\n            push(stack, expression[i]); \r\n\r\n        else if (expression[i] == ')') \r\n        { \r\n            while (!isEmpty(stack) &amp;&amp; peek(stack) != '(') \r\n                expression[++j] = pop(stack); \r\n            if (!isEmpty(stack) &amp;&amp; peek(stack) != '(') \r\n                return -1; \/\/ invalid expression              \r\n            else\r\n                pop(stack); \r\n        } \r\n        else \/\/ if an opertor\r\n        { \r\n            while (!isEmpty(stack) &amp;&amp; precedence(expression[i]) &lt;= precedence(peek(stack))) \r\n                expression[++j] = pop(stack); \r\n            push(stack, expression[i]); \r\n        } \r\n\r\n    } \r\n\r\n     while (!isEmpty(stack)) \r\n        expression[++j] = pop(stack); \r\n\r\n    expression[++j] = '&#92;0'; \r\n    printf( &quot;%s&quot;, expression); \r\n} \r\n\r\nint main()\r\n{\r\nchar expression[] = &quot;((p+(q*r))-s)&quot;; \r\n    covertInfixToPostfix(expression); \r\n    return 0; \r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_10609 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_10609 a\"),jQuery(\"#tab-content_10609\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Output:<\/strong><\/p>\n<pre><code>pqr*+s-<\/code><\/pre>\n<p><strong>Explanation<\/strong><br \/>\nThe program uses a stack, which is a data structure that follows the Last-In-First-Out (LIFO) principle, to convert the infix expression to postfix. The stack is implemented as an array of characters called stk. The maximum size of the stack is defined as MAX, which is set to 20 in this program. The program defines several functions to perform different operations on the stack. The isEmpty() function checks if the stack is empty, isFull() function checks if the stack is full, peek() function returns the top element of the stack without removing it, the pop() function removes and returns the top element of the stack, and push() function adds an element to the top of the stack.<\/p>\n<p>The checkIfOperand() function is used to check if a character in the expression is an operand (a variable or a constant). The precedence() function is used to determine the precedence of operators. In this program, the operators are +, -, *, \/, and ^ (exponentiation).The covertInfixToPostfix() function is the main function that performs the conversion from infix to postfix. It takes an infix expression as input and returns a postfix expression. The function uses a loop to iterate through each character in the infix expression. If the character is an operand, it is added to the output expression. If the character is an opening parenthesis, it is pushed onto the stack. If the character is a closing parenthesis, all operators are popped from the stack and added to the output expression until an opening parenthesis is encountered. If the character is an operator, all operators with higher or equal precedence are popped from the stack and added to the output expression, and then the operator is pushed onto the stack.<\/p>\n<p>After the loop has finished, any remaining operators on the stack are popped and added to the output expression. The output expression is then terminated with a null character and printed to the console. The main() function is the entry point of the program. It defines an infix expression ((p+(q*r))-s) and passes it to the covertInfixToPostfix() function to convert it to postfix notation. Finally, the program returns 0 to indicate successful completion.<\/p>\n<p><strong>Conclusion<\/strong><br \/>\nIn this blog, we have discussed the famous problem of how to convert Infix to a postfix program in C language, we hope this article will enhance your knowledge of stacks and logic building. Many companies like TCS, Wipro, Samsung, Squad Stack, and more asks about these types of problems in their hiring process. Practicing these questions builds your programming skills, also you can practice more questions on our <a href=\"https:\/\/mycode.prepbytes.com\/\" title=\"MYCODE\">MYCODE<\/a> platform.<\/p>\n<h2>Frequently Asked Question<\/h2>\n<p>FAQs on c program to convert infix to postfix<\/p>\n<p><strong>Q1. What is the advantage of using postfix notation over infix notation?<\/strong><br \/>\n<strong>Ans.<\/strong> The advantage of postfix notation over infix notation is that it simplifies the order of operations and eliminates the need for parentheses. In postfix notation, operators come after the operands they act on, so there is no ambiguity about the order of operations. This makes evaluating expressions more efficient and reduces the potential for errors.<\/p>\n<p><strong>Q2. How can I evaluate a postfix expression in C?<\/strong><br \/>\n<strong>Ans.<\/strong> To evaluate a postfix expression in C, you can use a stack to keep track of the operands as you read through the expression from left to right. When you encounter an operand, push it onto the stack. When you encounter an operator, pop the top two operands off the stack, apply the operator, and push the result back onto the stack. When you reach the end of the expression, the result will be the top element of the stack.<\/p>\n<p><strong>Q3. What are some common mistakes when converting infix expressions to postfix notation?<\/strong><br \/>\n<strong>Ans.<\/strong> Some common mistakes when converting infix expressions to postfix notation include not properly handling parentheses, not properly handling operators with the same precedence, and not properly handling unary operators. It&#8217;s important to carefully follow the rules of the shunting yard algorithm and to thoroughly test your implementation<\/p>\n<p><strong>Q4. Why is postfix notation more efficient for evaluating expressions?<\/strong><br \/>\n<strong>Ans.<\/strong> Postfix notation is more efficient for evaluating expressions because it eliminates the need for parentheses and simplifies the order of operations. In postfix notation, operators come after the operands they act on, so there is no ambiguity about the order of operations.<\/p>\n<p><strong><a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/basic-c-programs-examples\/\"><br \/>\nOther C Programs<\/a><\/strong><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-calculate-percentage-of-5-subjects\/\">C program to calculate percentage of 5 subjects<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-convert-binary-number-to-decimal-number\/\">C program to convert binary number to decimal number<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-convert-celsius-to-fahrenheit\/\">C program to convert celsius to fahrenheit<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-add-two-numbers\/\">C program to add two numbers<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-find-area-of-circle\/\">C program to find area of circle<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-find-roots-of-quadratic-equation\/\">C program to find roots of quadratic equation<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/c-programming\/c-program-to-reverse-a-number\/\">C program to reverse a number<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/c-program-for-merge-sort-for-linked-lists\/\">C program for merge sort for linked lists<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/c-program-for-performing-bubble-sort-on-linked-list\/\">C program for performing bubble sort on linked list<\/a><br \/>\n<a href=\"https:\/\/prepbytes.com\/blog\/linked-list\/c-program-to-reverse-a-linked-list\/\">C program to reverse a linked list<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In computer science, infix notation is a common way of representing mathematical expressions where operators are placed between operands. However, when it comes to evaluating expressions, postfix notation (also known as Reverse Polish Notation) can be more convenient and efficient. In postfix notation, operators come after the operands they act on. For example, the infix [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-10586","post","type-post","status-publish","format-standard","hentry","category-c-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C Program to Convert Infix to Postfix<\/title>\n<meta name=\"description\" content=\"Any operation can be expressed in infix, prefix and postfix, here we will see how to convert infix to postfix program in C language.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C Program to Convert Infix to Postfix\" \/>\n<meta property=\"og:description\" content=\"Any operation can be expressed in infix, prefix and postfix, here we will see how to convert infix to postfix program in C language.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-18T09:46:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-12T06:05:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668833413965-C%20Program%20to%20Convert%20Infix%20to%20Postfix.jpg\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"C Program to Convert Infix to Postfix\",\"datePublished\":\"2022-11-18T09:46:50+00:00\",\"dateModified\":\"2023-04-12T06:05:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/\"},\"wordCount\":1433,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668833413965-C%20Program%20to%20Convert%20Infix%20to%20Postfix.jpg\",\"articleSection\":[\"C Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/\",\"name\":\"C Program to Convert Infix to Postfix\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668833413965-C%20Program%20to%20Convert%20Infix%20to%20Postfix.jpg\",\"datePublished\":\"2022-11-18T09:46:50+00:00\",\"dateModified\":\"2023-04-12T06:05:54+00:00\",\"description\":\"Any operation can be expressed in infix, prefix and postfix, here we will see how to convert infix to postfix program in C language.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668833413965-C%20Program%20to%20Convert%20Infix%20to%20Postfix.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668833413965-C%20Program%20to%20Convert%20Infix%20to%20Postfix.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C Programming\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/c-programming\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"C Program to Convert Infix to Postfix\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C Program to Convert Infix to Postfix","description":"Any operation can be expressed in infix, prefix and postfix, here we will see how to convert infix to postfix program in C language.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/","og_locale":"en_US","og_type":"article","og_title":"C Program to Convert Infix to Postfix","og_description":"Any operation can be expressed in infix, prefix and postfix, here we will see how to convert infix to postfix program in C language.","og_url":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2022-11-18T09:46:50+00:00","article_modified_time":"2023-04-12T06:05:54+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668833413965-C%20Program%20to%20Convert%20Infix%20to%20Postfix.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"C Program to Convert Infix to Postfix","datePublished":"2022-11-18T09:46:50+00:00","dateModified":"2023-04-12T06:05:54+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/"},"wordCount":1433,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668833413965-C%20Program%20to%20Convert%20Infix%20to%20Postfix.jpg","articleSection":["C Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/","url":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/","name":"C Program to Convert Infix to Postfix","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668833413965-C%20Program%20to%20Convert%20Infix%20to%20Postfix.jpg","datePublished":"2022-11-18T09:46:50+00:00","dateModified":"2023-04-12T06:05:54+00:00","description":"Any operation can be expressed in infix, prefix and postfix, here we will see how to convert infix to postfix program in C language.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668833413965-C%20Program%20to%20Convert%20Infix%20to%20Postfix.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1668833413965-C%20Program%20to%20Convert%20Infix%20to%20Postfix.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/c-program-to-convert-infix-to-postfix\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"C Programming","item":"https:\/\/prepbytes.com\/blog\/category\/c-programming\/"},{"@type":"ListItem","position":3,"name":"C Program to Convert Infix to Postfix"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/10586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=10586"}],"version-history":[{"count":6,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/10586\/revisions"}],"predecessor-version":[{"id":15536,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/10586\/revisions\/15536"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=10586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=10586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=10586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}