Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C Language, write get_opnd() whose prototype is in opnd.h. M odify get_int() from chrutil.c . Write driver2.c that reads integer operands and writes them

In C Language, write get_opnd() whose prototype is in opnd.h. Modify get_int() from chrutil.c. Write driver2.c that reads integer operands and writes them to the screen using write_debug(). Then add the exponent operand types using the functions in your exponent.c.

// File: opnd.h /* This file contains the prototypes for funcitons in opnd.c */ int get_opnd(char ch); /* This function is given the first character of an operand. It reads the remaining characters of the operand and converts it to internal integer form. Operands may be a sequence of digit characters or a sequence of digits (the base) followed by a sequence of exponent characters, in which case get_opnd() computes the base to the exponent as its result. All characters are echoed to the display using Display Module routines. */ 
/* File: chrutil.c */ /* This file contains various utility functions for processing characters */ #include  #include "tfdef.h" #include "chrutil.h" /* Function converts ch to an integer if it is a digit. Otherwise, it prints an error message. */ int dig_to_int(char ch) { if (IS_DIGIT(ch)) return ch - '0'; printf("ERROR:dig_to_int: %c is not a digit ", ch); return ERROR; } /* Function converts a positive integer less than 10 to a corresponding digit character. */ char int_to_dig(int n) { if (n >= 0 && n < 10) return n + '0'; printf("ERROR:int_to_dig: %d is not in the range 0 to 9 ", n); return NULL; } /* Function reads the next integer from the input */ int getint() { int n = 0; int got_dig = FALSE; signed char ch; ch = getchar(); /* read next char */ while (IS_WHITE_SPACE(ch)) /* skip white space */ ch = getchar(); while (IS_DIGIT(ch)) { /* repeat as long as ch is a digit */ n = n * 10 + dig_to_int(ch); /* accumulate value in n */ got_dig = TRUE; #ifdef DEBUG printf("debug:getint: ch = %c ", ch); /* debug statement */ printf("debug:getint: n = %d ", n); /* debug statement */ #endif ch = getchar(); /* read next char */ } if(ch == EOF) return EOF; /* test for end of file */ if(!got_dig) return ERROR; /* test for no digits read */ return n; /* otherwise return the result */ } /* Function tests if c is an alphabetic letter. */ int letterp(char c) { if (IS_LOWER(c) || IS_UPPER(c)) return TRUE; return FALSE; } /* Function returns TRUE if c is a delimiter, i.e., it is a white space or a punctuation. Otherwise, it returns FALSE. */ int delimitp(char c) { if (whitep(c) || punctp(c)) return TRUE; return FALSE; } /* Function returns TRUE if c is white space; returns FALSE otherwise. */ int whitep(char c) { if (c == ' ' || c == '\t' || c == ' ') return TRUE; return FALSE; } /* Function returns TRUE if c is a punctuation; returns FALSE otherwise. */ int punctp(char c) { if (c == '.' || c == ',' || c == ';' || c == ':' || c == '?' || c == '!') return TRUE; return FALSE; } /* Function checks if c is a vowel. */ int vowelp(char c) { switch(c) { case 'a': case 'A': case 'e': case 'E': case 'i': case 'I': case 'o': case 'O': case 'u': case 'U': return TRUE; default: return FALSE; } } /* Function tests if c is printable. */ int illegal(char c) { if (IS_PRINT(c) || IS_WHITE_SPACE(c)) return FALSE; return TRUE; } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Upgrade Migration And Transformation Tips And Techniques

Authors: Edward Whalen ,Jim Czuprynski

1st Edition

0071846050, 978-0071846059

More Books

Students also viewed these Databases questions

Question

2. Why does unpredictability matter?

Answered: 1 week ago

Question

d. What language(s) did they speak?

Answered: 1 week ago