Reverse polish notation in C
here is the starter code :
/*
* File: main.c
* Author: MSU
*
* Created on March 13, 2019, 1:45 PM
*/
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZEI 8
#define MAXSIZEC 7
int top = -1;
int isempty(int stack[]);
int isfull(int stack[]);
int peek(int stack[]);
int pop(int stack[]);
int push(int data, int stack[]);
int printStack(int stack[]);
int size();
int main()
{
//push item on to the stack
int stack[8];
int ssize;
push(3, stack);
push(5, stack);
push(9, stack);
ssize = size();
printf("The size of the stack is: %d\n", ssize);
push(1, stack);
push(12, stack);
push(15, stack);
ssize = size();
printf("The size of the stack is: %d\n", ssize);
printf("Element at top of the stack: %d\n", peek(stack));
printStack(stack);
if(isfull(stack) ==1)
printf("Stack full\n");
else if(isempty(stack)== 1)
printf("Stack empty\n");
return 0;
}
int printStack(int stack[])
{
printf("Element: \n");
while(!isempty(stack)){
int data = pop(stack);
printf("%d\n", data);
}
}
int isempty(int stack[])
{
if(top == -1)
return 1;
else
return 0;
}
int isfull(int stack[])
{
if(top == MAXSIZEI)
return 1;
else
return 0;
}
int peek(int stack[])
{
return stack[top];
}
int pop(int stack[])
{
int data;
if(!isempty(stack)){
data = stack[top];
top = top - 1;
return data;
} else{
printf("Could not retrieve data, Stack is empty");
}
}
int push(int data, int stack[]){
if(!isfull(stack)){
top = top + 1;
stack[top] = data;
} else{
printf("Count not insert data. Stack is full.\n");
}
}
int size()
{
return top + 1;
}
6 years ago
10
Purchase the answer to view it

- updated2.c
- QUESTION 1
- Challenges Posed by Democracy
- Descriptive Statistics
- 21st Century Corporate Social Responsibility
- EHR
- Student-Centered Instructional Models
- Assignment
- My assignmet is answering questions about a movie. The movie is called.The Fog of War: Eleven Lessons from the Life of Robert S McNamara.
- Macro Economics HW
- Assignment 2: Review of a Nursing Research Article Select a nursing research article from the list below that includes a theoretical or conceptual framework and the exploration of a clinical problem. Identify the nursing research article components using