Question: Q) Separate this into separate header and code files, so that none of the functions are implemented inside the main.c 1 include 2 #include 3

Q) Separate this into separate header and code files, so that none of the functions are implemented inside the main.c  Q) Separate this into separate header and code files, so that
none of the functions are implemented inside the main.c 1 include 2
#include 3 4 #define MAXOP 100 5 #define NUMBER '0' 6 7
int getop(char []); 8 void push (double); 9 double pop(void); 10 11
int main() 12 { 13 int type; 14 double op2; 15 char

1 include 2 #include 3 4 #define MAXOP 100 5 #define NUMBER '0' 6 7 int getop(char []); 8 void push (double); 9 double pop(void); 10 11 int main() 12 { 13 int type; 14 double op2; 15 char s[MAXOP]; 16 17 while ((type=getop(s)) != EOF){ 18 switch(type){ case NUMBER: 20 push(atof(s)); 21 break; 22 case '+': 23 push(pop() + pop(); 24 break; 25 26 push(pop() pop()); 27 break; 28 case '-': 29 op2 = pop(); 19 case '*': 30 push(pop) - op2); 31 break; 32 case '/': 33 op2= pop(); 34 if (op2 != 0.0) 35 push(pop()/op2); 36 else 37 printf("error: zero divisor "); 38 break; 39 case ' ': 40 printf("\t%.8g ", pop()); 41 break; 42 default: 43 printf("error: unknown command %s ", s); 44 break; 45 46 } 47 48 // ADD TEST CODE HERE FOR ALL THREE FUNCTIONS 49 50 return 0; 51 } 52 53 #define MAXVAL 100 54 int sp=0; 55 double val[MAXVAL]; 56 57. void push(double f){ 58 if (sp 0) 66 return val[--sp]; 67 else{ 68 printf("error: stack empty "); 69 return 0.0; 70 } 71 } 72 73 #include 74 75 int getch(void); 76 void ungetch(int); 77 78 /* gets the next operator or operand */ 79 int getop(char s[]){ 80 int i, c; 81 82 while( (s[0] = c = getch() ''Il C == '\t') 83 ; 84 S[1]='\0'; 85 if(!isdigit(c) && c != '.') 86 return c; i 87 0; 97 88 if(isdigit(c)) 89 while (isdigi (s[++i] = C = getch())) 90 ; 91 if (c 92 while (isdigit(s[++i] = C = getch())) 93 94 s[i] '0'; 95 if (c != EOF) 96 ungetch(); return NUMBER; 98 } 99 100 #define BUFSIZE 100 101 102 char buf[BUFSIZE]; 103 int bufp =0; 104. /* get the next character, either from standard input or 105 from the buffer (of character's that we placed 'back on the buffer) 106 */ 107. int getch(void){ 108 return (bufp > 0) ? buf[--bufp] : getchar(); 109} 110 111. /*populate the local buffer with characters you meant to 'put back' b/c you 112 read too far*/ 113 void ungetch(int c){ 114 if (bufp >= BUFSIZE) 115 printf("ungetch: too many characters "); 116 else 116 117 118 } else buf[bufp++] = c

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!