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

C++ version in your textbook page 166 – 171. Your instructor will also give hint

ID: 3588447 • Letter: C

Question

C++ version in your textbook page 166 – 171. Your instructor will also give hints and examples in class and you should incorporate them into your code. The input for your code should be a text file containing a simple arithmetic expression using named variables, parentheses, and integers. The output should be to the screen and it should consist of a stream of pairs of identifiers and lexemes corresponding to the input. For example , if we input : (sum + 47)/total, the screen output would as shown in the console window below. I have included pictures from textbook pages

/* front.c a lexical analyzer system for simple arithmetic expressions */ #include #include /* Global declarations / /*Variables */ int charClass; char lexeme [100]; char nextChar; int lexLen; int token; int nextToken; FILE *in_fp, *fopen ();

Explanation / Answer

#include #include #include class Cpu { public: virtual int dummy( int, int ) {} private: virtual int add_( int a, int b ) { return a + b; } /* A */ virtual int sub_( int a, int b ) { return a - b; } /* B */ virtual int mul_( int a, int b ) { return a * b; } /* C */ virtual int div_( int a, int b ) { return a / b; } /* D */ virtual int mod_( int a, int b ) { return a % b; } /* E */ virtual int and_( int a, int b ) { return a & b; } /* F */ virtual int or_( int a, int b ) { return a | b; } /* G */ virtual int xor_( int a, int b ) { return a ^ b; } /* H */ }; int main( int argc, char* argv[] ) { typedef int (Cpu::*Memfun)( int, int ); union { Memfun fn; unsigned char ptr[6]; } u; Cpu cpu; u.fn = &Cpu::dummy; assert( argc == 4 ); int p1 = atoi( argv[ 1 ] ); int p2 = atoi( argv[ 3 ] ); char op = argv[2][0]; assert( op >= 'A' && op
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