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

Write a preprocessor directive to accomplish each of the following: a) Define sy

ID: 3829832 • Letter: W

Question

Write a preprocessor directive to accomplish each of the following: a) Define symbolic constant TRUE to have the value 1. b) Define symbolic constant FALSE to have the value 0. c) If symbolic constant YES is defined, undefine it and redefine it as 1. d) Define a macro. AREA, that takes a single argument and compotes the are, of a square. e) Define macro SUM that will sum two numbers. f) Define macro MIN2 that will determine the smallest of two numeric values. Write a macro that computes the remainder when n is divided by 4. Let DOUBLE be the following macro: define DOUBLE (x) 2 * x a) What is the value of DOUBLE (1 + 2)? b) What is the value of 4/DOUBLE (2)? c) Fix the definition of double. For each of the following macros, give an example that illustrates a problem with the macro and show how to fix it. a) # define AVG (x, y) (x + y)/2 b) # define AREA (x, y) (x) + (y)

Explanation / Answer

1(a) #define TRUE 1


(b) #define FALSE 0


(c)#ifdef YES
#undef YES
#define YES 1

d)  #define Area(x) x*x

e)  #define Sum(x, y) x + y




Thanks, let me know if there is any concern.

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