Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me for this homework problem, thanks!! Read text section 1.4.2. Macros are available in most high-level programming languages. The body of a macro

Please help me for this homework problem, thanks!!

  1. Read text section 1.4.2. Macros are available in most high-level programming languages. The body of a macro is simply used to replace a macro-call during the preprocessing stage. A macro introduces a "true inline" function that is normally more efficient than an "outline" function. However, macros suffer from the side-effect, unwanted, or unexpected modifications to variables. Macros should be used cautiously. The main purpose of the following programs is to demonstrate the differences between a function and a macro. Other purposes include demonstrating the differences between different programming environments, and learning different ways of writing comments, formatted input and output, variable declaration and initialization, unary operation ++, macro definition/call, function definition/call, if-then-else and loop structures, etc.

Observe each of the functions below and understand their functionality. You can use either

GNU gcc under Unix or Visual Studio to implement the code in this question

int subf(int a, int b) {

return a - b;

}

int cubef(int a) {

return a * a * a;

}

int minf(int a, int b) { if (a <= b) {

return a;

}

else {

return b;

}

}

int oddf(int a) { if (a % 2 == 1) { return 1;

}

else {

return 0;

}

2.1 Write four macros to re-implement the given four functions. Name them: subm, cubem, minm, and oddm, respectively. [10 points]

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

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

Find the magnitude of a. b. c.

Answered: 1 week ago

Question

8. Explain the difference between translation and interpretation.

Answered: 1 week ago

Question

10. Discuss the complexities of language policies.

Answered: 1 week ago

Question

1. Understand how verbal and nonverbal communication differ.

Answered: 1 week ago