Question

2. Consider the statement double ans = 20.0/multiply(2+3) For each of the below mentioned four versions of the function macro

PLEASE GIVE C++ CODE OF THE 2nd and 3rd Question.
PLEASE CHECK YOUR CODE BEFORE POSTING IT
I WILL UPVOTE IF THE ANSWER IS CORRECT!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

As per HOMEWORKLIB POLICY, I am answering only the first question. In order to get answers of more question please upload the remaining questions separately:

Below is the answer related to question 2.

Q2.) Below is the required C++ code:

#include<iostream>

using namespace std;

//#define multiply(x) x*x
//#define multiply(x) (x*x)
//#define multiply(x) (x)*(x)
#define multiply(x) ((x)*(x))

int main()
{
double ans = 20.0/multiply(2+3);
cout<<ans<<endl;
return 0;
}//end of main function

Note: run using 1 macro at a time, and check the result.

a.) 19

b.) 1.81818

c.) 20

d.) 0.8

Hope it helps, give it a thumbs up.

Feel free to comment in case of any query.

Add a comment
Know the answer?
Add Answer to:
PLEASE GIVE C++ CODE OF THE 2nd and 3rd Question. PLEASE CHECK YOUR CODE BEFORE POSTING...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C programming lab: Description: In this lab you will write a program that will contain two...

    C programming lab: Description: In this lab you will write a program that will contain two functions, setlsbs() and getlsbs(). These functions will use bitwise operators to embed and extract "hidden" bits in a character array. Write a program to test your functions as follows: Obtain a random number seed from the command line of your program using command line arguments. Initialize an array p of 8 unsigned char with random numbers from 0 to 255 Initialize a separate unsigned...

  • This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation...

    This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT