Posts

Showing posts with the label push-pop

Write a C program to convert Infix to Postfix Expression

C Program to convert infix expression to equivalent postfix Table of Contents Problem Defination Source Code Output Program Problem Definition We will be provied a infix expression and all we have to do is to convert that equation into its equivalent postfix expression using C Language. Solution/Source Code Here is the Souce C code to convert an infix expression to its equivalent postfix expression using stack. We will be using here few functions to impliment the code easily. The below code snippets are successfully compiled and runned on DEV C++ Windows 10 Platform. Output results are also shown below. #include<stdio.h> #include<string.h> #define MAX 50 char stack[MAX]; int top=-1; void push(char a){ stack[++top]=a; } int pop(){ return(stack[top--]); } int pre(char s){ int a; switch(s){ case '+': case '-': a=1; break; case '*': case '/': case '%...