HOMEWORK PROBLEM : Given the following man program in C which calls a function t
ID: 3632290 • Letter: H
Question
HOMEWORK PROBLEM :Given the following man program in C which calls a function toPOstfix to convert a string in
infx notation to one in postfix notation.
int main(int argc, char* argv[])
{
char infixstream[100];
char postfixstream[100];
printf(" Enter a mathematical expression :");
scanf("%s",infixstream);
printf(" ");
toPostfix(infixstream,postfixstream);
printf(" The postfix equivalent of the input expression :");
printf("%s",infixstream);
printf(" ");
}
Write an assembly language function toPostfix starting with the code given below to accept an
infix notation formula and convert it to postfix (reverse polish ) notation.
Please note that every line of your code should be explained. You should submit
1- Algorithm developed for the conversion
2- Source code
3- Execution and output examples
Example code
.globl _toPostfix
_toPostfix:
pushl %ebp
movl %esp,%ebp
// YOUR CODE HERE
ret
Explanation / Answer
#include #include #include static char *s; static int top; int main ( int argc, char *argv[] ) { char *a = argv[1]; int i, n = strlen ( a ); /* Initialize the stack */ s = malloc ( n * sizeof *s ); top = 0; for ( i = 0; i = '0' && a[i]Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.