Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to make a reverse polish notation calculator in c that can work for any numb

ID: 3635776 • Letter: H

Question

How to make a reverse polish notation calculator in c that can work for any number of brackets and without using math library

Explanation / Answer

#include #include #include #include #include #define STACKSIZE 1000 int stack_pointer = 0; int STACKDISPLAY = 0; long double stack[STACKSIZE] = {0.0}; int string_equal(const char* first, const char *second) { return (strcmp(first, second) == 0); } void show_stack(char message[]) { /* * this printout may be helpful for debugging and understanding what is * going on */ int i; if (!STACKDISPLAY) { return; /* return unless STACKDISPLAY is turned on */ } printf("Displaying stack at end of function %s Stack contents: ", message); for (i = stack_pointer; i >= 0; i--) printf("stack[%d] = %f ", i, stack[i]); printf(" "); } double pop_off_stack(void) { double return_value; return_value = stack[stack_pointer]; /* return value on the top of the * stack */ if (stack_pointer > 0) /* move the stack pointer down if not at the*/ /* lowest point */ { stack_pointer--; } show_stack("pop_off_stack"); return return_value; } double top_of_stack_value(void) { return stack[stack_pointer]; /* just return the value on the top of the * stack */ } double push_onto_stack(double value) { int i; stack[++stack_pointer] = value; /* put value on the top of the stack */ /* * check to see if stack full, if so, move down, causing the bottom value * to disappear */ assert(stack_pointer < (STACKSIZE + 1)); if (stack_pointer == STACKSIZE) { for (i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote