Problem Solving With C++ (Looseleaf) - With Access
9th Edition
ISBN: 9780133835267
Author: SAVITCH
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 5.5, Problem 23STE
Program Plan Intro
Assert macro:
- It denotes a tool to ensure that expected conditions are true at assert statement location.
- If condition does not meet, then program displays error message and aborts.
- The assert definition is been included in program with statement “#include<cassert>”.
- The statement “assert(bool_expr)” is inserted to use “assert”, the “bool_expr” denotes a Boolean expression that should be evaluated to true.
- The assert statement denotes a macro, that is similar to function.
- The assert macros can be disabled by adding “#define NDEBUG” before include statement.
Given statement:
Explanation:
- The given statement denotes an expression with variables “x”, “y” and “z”.
- It updates the value of “x”.
- The value of “z” should not be zero.
- If the value becomes zero, then it displays division by zero error.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The Problem: How do you create a macro that performs two statements.For example we wish to create a cleanup macro:#define CLEAN_RETURN \ close(in_fd);close(out_fd); return;But this code doesn't work if we put it in an if statement:if (done) CLEAN_RETURN;Expanding this we get:if (done) close(in_fd);close(out_fd); return;Let's add a little whitespace for clarity:if (done) close(in_fd);close(out_fd);return;This is not what we intended. One “solution” is to enclose the statementsin {}.#define CLEAN_RETURN \ { close(in_fd);close(out_fd); return; }Now our if statement expands to:if (done) { close(in_fd);close(out_fd); return; };This works. Sort of. The problem is if we try an if / else statement:if (done) CLEAN_RETURN;else not_done_yet();This gives us a syntax error when we try and compile it. Why?Let's look at the expanded code:if (done) { close(in_fd);close(out_fd); return; };else not_done_yet();There's an extra semicolon on the line. This didn't bother us when therewas no else, but now…
Which of these commands stops a macro from expanding?
Briefly explain macro procedure
Chapter 5 Solutions
Problem Solving With C++ (Looseleaf) - With Access
Ch. 5.1 - What is the output of the following program?...Ch. 5.1 - Are you required to have a return statement in a...Ch. 5.1 - Suppose you omitted the return statement in the...Ch. 5.1 - Prob. 4STECh. 5.1 - Prob. 5STECh. 5.1 - Is a call to a void function used as a statement...Ch. 5.2 - What is the output of the following program?...Ch. 5.2 - What would be the output of the program in Display...Ch. 5.2 - What would be the output of the program in Display...Ch. 5.2 - Prob. 10STE
Ch. 5.2 - Write a void function definition for a function...Ch. 5.2 - Prob. 12STECh. 5.3 - Prob. 13STECh. 5.3 - Prob. 14STECh. 5.3 - Rewrite the function declaration comment for the...Ch. 5.3 - Prob. 16STECh. 5.4 - Prob. 17STECh. 5.4 - Prob. 18STECh. 5.4 - Prob. 19STECh. 5.4 - Prob. 20STECh. 5.4 - Prob. 21STECh. 5.4 - Write a stub for the function whose function...Ch. 5.5 - Prob. 23STECh. 5.5 - Prob. 24STECh. 5.5 - Prob. 25STECh. 5 - Write a function that computes the average and...Ch. 5 - Write a program that reads in a length in feet and...Ch. 5 - Write a program like that of the previous exercise...Ch. 5 - (You should do the previous two Practice Programs...Ch. 5 - Write a program that reads in a weight in pounds...Ch. 5 - Write a program like that of the previous exercise...Ch. 5 - (You should do the previous two Practice Programs...Ch. 5 - (You need to do Practice Programs 4 and 7 before...Ch. 5 - The area of an arbitrary triangle can be computed...Ch. 5 - Write a program that converts from 24-hour...Ch. 5 - Write a program that requests the current time and...Ch. 5 - Modify your program for Programming Project 2 so...Ch. 5 - Write a program that tells what coins to give out...Ch. 5 - In cold weather, meteorologists report an index...Ch. 5 - Prob. 6PPCh. 5 - Write a program that inputs a date (for example,...Ch. 5 - Complete the previous Programming Project and...
Knowledge Booster
Similar questions
- Computer Science 8. Write a macro that: a. Ask users with an input box which information they want to find. The possibilities for input are: 1. Cancelled 2. Received 3. Refund 4. complete b. Based on the input, the macro determines how many sales of the chosen kind exist in the 'Sales data' and shows the result in a message box. Use the do-until function to solve this solution .arrow_forwardWrite a definition of a macro that computes a circle area, where the radius value is passed to the macro. NOTE: area=PI x radius x radius, and PI=3.141592.arrow_forwardWhich formula do I use? DCOUNTA? i would appreciate the help. Record a macro, which will ask the user for the STATE (using InputBox function) and then calculate number of our customers that meets that criteria (i.e. counters number of customers that lives in the STATE typed in that inputbox)? Create macro button called Question1 on Customers sheet so that we can replay this macro.arrow_forward
- Write a macro named mPromptInteger that displays a prompt and inputs an integer fromthe user. Pass it a string literal and the name of a doubleword variable. Sample call:.dataminVal DWORD ?.codemPromptInteger "Enter the minimum value", minValarrow_forwardShow the expanded code produced by the following statement that invokes the mWriteString macro from Section 10.2.5:mWriteStr namePromptarrow_forwardCreate a simple tik tak toe python game program between a bot and input from the user while using these requirements and do not use break return the values instead. Requirements: 3 Functions in a separate module file a. Atleast 4-5 Parameters / arguments used b. Return values used for each statement 2. Main file created a. Main function created b. Main function used appropriately 3. Decision structure used 4. Repetition structure used 5. Comment/header/style 6. Purpose of code is clear / program has a clear purpose 7. Must Include a menu in the program 8. Use of atleast 3-4predefined modules for example (math/random) .arrow_forward
- Prepare a dataset with the name of 10 different countries with the number of total corona affected people. Use macro to find the average number of corona affected people. Now create a button which can show the average by using that recorded macro. Now create a dataset with the data of total death in corona for 10 different countries. Apply the recorded macro in a button to show the average death. Inside the excel file please mention the name of your recorded macro file, anywhere in the same tab.arrow_forwardUse python please You are the manager of a £100 million portfolio, and you have 6 investment options: - First Mortgages: return 9% and risk score 3- Second Mortgages: return 12% and risk score 6- Personal Loans: return 15% and risk score 8- Commercial Loans: return 8% and risk score 2- Government Securities: return 6% and risk score 1- Saving Account: return 3% and risk score 0 The current regulation requires that the amount allocated in second mortgages and personal loans (combined) should not exceed the amount allocated in first mortages. Given this information: a) Ignoring the risk involved in the different investment options, what is the profit maximizing allocation of resources? What are the expected profits? b) Now, you have to consider the risk associated with the investments. The average risk of your portfolio cannot exceed 5. What is the profit maximizing allocation of resources? What are the expected profits? The average risk is computed as follows:Av=rixi/xi where: xi is…arrow_forwardUse python please You are the manager of a £100 million portfolio, and you have 6 investment options: - First Mortgages: return 9% and risk score 3- Second Mortgages: return 12% and risk score 6- Personal Loans: return 15% and risk score 8- Commercial Loans: return 8% and risk score 2- Government Securities: return 6% and risk score 1- Saving Account: return 3% and risk score 0 The current regulation requires that the amount allocated in second mortgages and personal loans (combined) should not exceed the amount allocated in first mortages. Given this information: a) Ignoring the risk involved in the different investment options, what is the profit maximizing allocation of resources? What are the expected profits? b) Now, you have to consider the risk associated with the investments. The average risk of your portfolio cannot exceed 5. What is the profit maximizing allocation of resources? What are the expected profits?arrow_forward
- It is desired to write a #define macro to compute the product of two numbers. What is the correct macro? Group of answer choices #define multiply (return(a*b)) #define multiply(a,b) (a*b) #define multiply(a,b) (int a*int b) #define multiply (int a, b; return(a*b)) ============= What does the function fopen return? Group of answer choices an integer a FILE pointer it returns nothing the contents of the file it is opening =============== Consider the following code fragment: int main (int argc, char* argv[]) { cout<<argc; return 0; } The code is compiled and executed from the terminal as: .\a.out What will be the output? Group of answer choices 0 1 argc -1arrow_forwardWrite a statement using the IF directive that checks the value of the constant macro parameter Z; if Z is less than zero, display a message during assembly indicating that Z is invalidarrow_forwardWrite a macro named mDumpMemx that receives a single parameter, the name of a variable.Your macro must call the mDumpMem macro from the book’s library, passing it the variable’soffset, number of units, and unit size. Demonstrate a call to the mDumpMemx macro.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Np Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:CengageProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage