Posts

Showing posts with the label conversions

Infix to postfix conversion using stack

//  We genrally read infixes as a+b but computers need things in postfix i.e  +ab  with pirority in //symbols , // if you want to know the concept   https://codeburst.io/conversion-of-infix-expression-to-postfix-expression-using-stack-data-structure-3faf9c212ab8 // if you already know the concept then head on to this program below :) #include<bits/stdc++.h> using namespace std; int priority(char c) {     if((c=='^'))     {         return 3;     }     else if(c=='*'||c=='/')     {         return 2;           }     else if(c=='+'||c=='-')     {         return 1;     }     else     {         return -1;     } } void infixtopostfix(string s) { string os; stack<char> st; int i; char c; for(i=0;i<s.length();i++) ...