"c program to convert infix to postfix" Code Answer's

You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "c program to convert infix to postfix" answered properly. Developers are finding an appropriate answer about c program to convert infix to postfix related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like c program to convert infix to postfix. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on c program to convert infix to postfix. 

infix to postfix program in c++

By Careful CowCareful Cow on Dec 01, 2020
/*https://github.com/Sudhanshu1304/Stack-Application*/

#include <iostream>
#include<string>
using namespace std;



class Stack{


private:


    char A[5];
    int Size;

public:
    int top;
    Stack(){

        top=-1;
        Size=sizeof(A)/sizeof(char);

    }



    bool IsFull(){

        if(top==Size-1){
            return true;
        }
        else{
            return false;
        }
    }

    bool IsEmpty(){

        if(top==-1){
            return true;
        }
        else{
            return false;
        }
    }

    char peek(){

        return A[top];
    }

    void Push(char val){

        if (IsFull()==false){
            top++;
            A[top]=val;
        }
        else{
            cout<<"\nThe Stack is Full"<<endl;
        }
    }

    char Pop(){

        if(IsEmpty()==false){
            char temp=A[top];
            A[top]='0';
            top--;
            return temp;
        }
        else{
            return '-1';
        }

    }

    void Show_Stack(){


        for(int i=0;i<top+1;i++){
            cout<<A[i];
        }


    }

};


int Search(char A){


    string CHAR[]={"([","{)","]}","+-","*/","^$"};
    int Size=(sizeof(CHAR)/sizeof(string));

    for(int i=0;i<Size;i++){

        if(A==CHAR[i][0]){
                if(i+i>=6){
                    return i+i;
                }
                else{
                    return i+i+0;
                }

        }
        else if(CHAR[i][1]==A){
             if(i+i>=6){
                    return i+i;
                }
                else{
                    return i+i+1;
                }
        }
    }
    return -1;

}




void Display(char ch,string vari, Stack &s){

    int Size=s.top+1;


    cout<<"\n   "<<ch<<"           ";
    s.Show_Stack();
    for(int i=0;i<10-Size;i++){
        cout<<" ";
    }
    cout<<vari<<endl;

}


int main(){

    Stack STACK;
    char temp;
    string exp;//"A+B*C";
    cout<<"Enter Your Expression :";
    cin>>exp;

    string out="";
    cout<<"\n\nExpression   Stack   Postfix\n"<<endl;
    for(int i=0;i<exp.size();i++){

        temp=exp[i];

        int ab=Search(temp);

        if (ab!=-1){

            /* If We ENCOUNTER CLOSING BRACKETS*/
            if(ab<=5 && ab>=3){



                while(Search(STACK.peek())>2){
                    char val=STACK.Pop();
                        out=out+val;

                    Display(temp,out,STACK);
                }
                STACK.Pop();
                Display(temp,out,STACK);
                }
            /* Search Precedence*/
            else{
                if (Search(temp)>=0 && Search(temp)<=2){
                    STACK.Push(temp);
                    Display(temp,out,STACK);
                }

                /* If TOP < Temp */

                else if(Search(STACK.peek())<ab){

                        STACK.Push(temp);
                        Display(temp,out,STACK);
                }
                else{
                    /* if STACK= +,* and temp= + then we have to remove two times */


                    while(Search(STACK.peek())>=ab){

                        char val=STACK.Pop();
                            out=out+val;
                        Display(temp,out,STACK);
                    }
                    STACK.Push(temp);
                    Display(temp,out,STACK);
                }
            }
        }
        /* If an Alphabet */
        else{

            out=out+temp;
            Display(temp,out,STACK);

            }


    }
    while(STACK.IsEmpty()==false){

        char val=STACK.Pop();

            out=out+val;
        Display(temp,out,STACK);

    }
    cout<<"\n\nFINAL STRING : "<<out<<endl;


}

Add Comment

1

All those coders who are working on the C++ based application and are stuck on c program to convert infix to postfix can get a collection of related answers to their query. Programmers need to enter their query on c program to convert infix to postfix related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about c program to convert infix to postfix for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of c program to convert infix to postfix while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "c program to convert infix to postfix". Visit this developer's friendly online web community, CodeProZone, and get your queries like c program to convert infix to postfix resolved professionally and stay updated to the latest C++ updates. 

C++ answers related to "c program to convert infix to postfix"

View All C++ queries

C++ queries related to "c program to convert infix to postfix"

c program to convert infix to postfix infix to postfix program in c++ infix to prefix using cpp linked list program prefix and postfix operator overloading in c++ Write a program to sort an array 100,200,20, 75,89.198, 345,56,34,35 using Bubble Sort. The program should be able to display total number of passes used for sorted data in given data set. c program to add two numbers sfml base program Name one example of a “decider” program that you regularly encounter in real life. sfml basic program binary search program c++ c++ program for addition of two numbers using functions c++ calculator program using switch case program to calculate factorial of number in c++ polymorphism-program.cpp compile c++ program tower of hanoi program in c Write a program to find the sum of all sub-arrays of a given integer array. write a program to implement stack using array sfml default program c++ object program if else program in c ++ run c++ program in mac terminal program to know if a number is prime running a c++ program in visual studio code cannot edit in read only editor Write a program to print following pattern; 1 1 2 1 2 3 1 2 3 4 insertion sort in c++ program c++ prime number program c++ program for matrix addition c++ program to reverse an array all pair shortest path algorithm in c with program c++ hello world program Write a program that inputs test scores of a student and display his grade cpp program to find average of n numbers how to end a c++ program early c++ input from terminal when program is called Application of c++ in youtube program c++ program to find gcd of 3 numbers c++ program to generate prime numbers run program until ctrl-d c++ Write a C++ program using class and objects. You have to define multiple-member functions outside class and all those functions will be the same name c++ program to input and print text using Dynamic Memory Allocation.loop "how we write a program for" time swap" in c plus plus only with string" fcfs preemptive scheduling program in c++ Write a c++ program to print number triangle. c ++ Program for addition of two matrix in diagonal using pointers c++ program that calculates the distance covered by a vehicle given the speed and time. menu driven program to delete in linked list how to type a vertical stack program c++ c++ program to count number of characters of words in a file using stringstream cpp program to temove space from string Write a program that inputs time in seconds and converts it into hh-mm-ss format Write a c++ program that reads a sentence (including spaces) and a word, then print out the number of occurrences of the word in the sentence write a program that simulates the rolling of two dice in c++ write a c++ program that reads ten strings and store them in array of strings, sort them and finally print the sorted strings simple program for sign in and sign up in c++ c++ program to print fibonacci series malloc c++ program set keybinding for compiling c++ program in neovim c++ program how to let the user choose different game modes Write a program to implement Liang-Bersky line clipping algorithm Create a program that finds the minimum value in these numbers bubble sort program in c++ how to run a c++ program in the background hello world program in c++ c++ how to create a program that stores details Dfs program in c++ how to make a c++ iostream program restart when finished Write a program in C++ to find post-order predecessor of a node in a Binary Tree program to swap max and min in matrix bracket balancing program in java convert vector to set c++ how to convert qt string to string convert set to vector c++ convert binary to decimal c++ stl convert entire string to lowercase c++ convert whole string to uppercase c++ convert stirng to int c++ c++ cli convert string to string^ convert to lowercase c++ convert integer to string c++ convert string to char c++ convert decimal to binary in c++ convert string to stream c++ convert int to binary string c++ convert all characters in string to uppercase c++ how to convert int to string c++ convert refference to pointer c++ how to convert n space separated integers in c++ convert a int to string c++ how to convert a string to a double c++ convert characters to lowercase c++ c++ convert lowercase to uppercase convert string to char array c++ convert string to number c++ how to convert from string to int in c++ COnvert string to char * C++ convert string to int c++ convert from uppercase to lowercase c++ how to convert integer to string in cpp convert long int to binary string c++ convert whole string to lowercase c++ how to convert int to std::string c++ convert const char* to int convert letters to uppercase in c++ convert all strings in vector to lowercase or uppercase c++ convert ascii char value to hexadecimal c++ c++ convert int to cstring how to convert array into set in c++ why convert char* to string c++ convert char to int c++ c++ convert int to double Convert a hexadecimal number into decimal c++ C++ convert integer to digits, as vector c++ convert to assembly language C++ convert vector of digits into integer convert c++ to mips assembly code online c++ convert template function to normal function Character convert c++ convert GLFWwindow* to IntPtr convert array to set c++ convert c++ code to c online convert int to string c++ c++ convert const char* to LPCWSTR convert char to char* Convert string to char* c++ c++ convert char to string

Browse Other Code Languages

CodeProZone