#include <iostream>
#include <stdio.h>
#include <string.h>
char stack[100];
int top = -1;
void printArray(int array[], int size) {
int i;
for ( i = 0; i < size; i++)
{
printf("%d,", array[i]);
}
printf("\n");
}
int isempty() {
if(top == -1)
return 1;
else
return 0;
}
int isfull() {
if(top == 99)
return 1;
else
return 0;
}
int peek() {
return stack[top];
}
int pop() {
int data;
if(!isempty()) {
data = stack[top];
top = top - 1;
return data;
}else {
printf("Could not retrieve data, Stack is empty.\n");
}
}
int push(int data) {
if(!isfull()) {
top = top + 1;
printf("push %d, top is %d\n", data, top);
stack[top] = data;
//printf("push stack[top] = data, top is %d\n", top);
}else {
printf("Could not insert data, Stack is full, top is %d.\n",
top);
}
}
int eval(int op1, int op2, char operate) {
switch (operate) {
case '*': return op2 * op1;
case '/': return op2 / op1;
case '+': return op2 + op1;
case '-': return op2 - op1;
default : return 0;
}
}
int processexpr(char expr[])
{
// write this function
int i = 0;
char ch;
int val;
int size = strlen(expr);
while (expr[i]!='\0') {
ch = expr[i];
if(ch=='=')
return val;
if (isdigit(ch)) {
push(ch-'0');
}
else {
int op1 = peek();
pop();
int op2 = peek();
pop();
val = eval(op1, op2, ch);
push(val);
}
i++;
}
return val;
}
int main() {
char expr[100] = "31+=";
int x = processexpr(expr);
printf("%s %d\n", expr, x);
// make your own postfix expression to test
// and print out the result
}
===================================
See Output

Thanks
(Using C++) Create a function that will solve integer postfix equations. (must implement own stack, can’t...
By using PYTHON language Postfix to Infix using Stack Develop a stack application that can convert Postfix notation to Infix notation using the following algorithm. In your stack application, you can use only two stacks, one for a stack that can store Postfix notation, and the other is a stack to store infix notation. Also, it would help if you had a function to distinguish between an operation or an operand. Input A B C * + D E /...
This project is designed to practice with OOP, stack data structure, its applications, and C++/Java programming language. You will write a program that reads an infix expression, converts it to a postfix expression, evaluates the postfix expression, and prints out the answer. You must define and implement your own Stack class and a Calculator class. Your Stack class supports standard basic stack operations and you can implement it with an array or a linked list. You should create a class...
Using ADT Stack: Evaluating infix expressions by converting them to postfix expressions Postfix notation: In a postfix expression, a binary operation follows its two opperands. The order of the operands in a infix expression is the same as in the corresponding postfix expression but the order of the operators might change based on the precedence of the operators and the existing of paranthses. Infix Postfix a + b a b + (a + b) * c a b + c...
Write a program that uses a stack to reverse its inputs. Your
stack must be generic and you must demonstrate that it accepts both
String and Integer types. Your stack must implement the following
methods:
push,
pop,
isEmpty (returns true if the stack is empty and false
otherwise), and
size (returns an integer value for the number of items in the
stack).
You may use either an ArrayList or a LinkedList to implement
your stack. Also, your pop method must...
I really need help with a stack class that takes integer values for expression processing. Here are the requirements for the assignment: Remove any whitespace between characters from the input. Verify there are no invalid characters in the input, and if there are then print an error message. Print the expression out as an infix expression. Convert that to a postfix expression and print it. Evaluate the postfix expression and print the result (invalid expressions should print an error message)....
I need assistance with this code. Is there any way I can create
this stack class (dealing with infix to postfix then postfix
evaluation) without utilizing <stdio.h> and
<math.h>?
____________________________________________________________________________________________
C++ Program:
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
using namespace std;
//Stack class
class STACK
{
private:
char *str;
int N;
public:
//Constructor
STACK(int maxN)
{
str = new char[maxN];
N = -1;
}
//Function that checks for empty
int empty()
{
return (N == -1);
}
//Push...
Using Windows API perform following exercise: Implement your own version of the ReadString procedure, using stack parameters. Pass it a pointer to a string and an integer, indicating the maximum number of characters to be entered. Return a count (in EAX) of the number of characters actually entered. The procedure must input a string from the console and insert a null byte at the end of the string (in the position occupied by 0Dh). See Section 11.1.4 for details on...
Create a C++ program. Include comment, input and output
file.
STACK IMPLEMENTATION USING AN link
list
IMPLEMENT THE FOLLOWING STACK OPERATIONS using a
TEMPLATED CLASS.
WRITE ALL THE FULL-FUNCTION DEFINITIONS NEEDED for the
OPERATIONS.
OUTPUT: PRINT ALL THE ELEMENTS ON THE STACK.
Stack Operations initializestack: Initializes the stack to an empty state. isEmptyStack: Determines whether the stack is empty. If the stack is empty, it returns the value true; otherwise, it returns the value false. isFul1stack: Determines whether the stack...
Convert infix to postfix, and evaluate postfix using custom Stack created using a singly linked list. This is only supposed to use THAT method, calling a normal Stack will give me a zero. I do have the conversion to postfix, but there may be error in there. But the main problem currently is the evaluation of postfix. I keep getting an error that I made for an empty stack, which I will include. For testing it is only supposed to...
Java please
5. Using the following postfix expressions, use a class) to stack (or the method we used in (12 pts-6 eaeh) solve them producing a final result. (a) 69 5 725 7*+-18 25 5,2025 20%+ (b) 2 3+ 5-6 78+ 45 5 % 12 3/++ -