Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
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
What benefits can you get from using a function?
Z Bank wants you to create a simple python program for calculating interest rate and Total balance for their customers. The program should start by reading Name of client, account number, credit amount, credit type and credit term (credit term means number of years to clear the credit).
Then you need to do the following:
Create a void function that will display “Z Bank, Nizwa welcomes you
Mr/Ms :<name of client>”
Create a function with return value and with parameters that will compute interest rate based on credit type and credit amount.
interest rate is 8% of credit amount if it is Gold credit.
9% of credit amount if it is Student credit.
10% of credit amount if it is Business credit.
13% of credit amount if it is personal credit
Create a function with return value that will accept the computed interest rate as one of…
I'd like a bank records system code using structures and files.
Age Project -8 Using structures and files: Create a C ++ program for the bank records system.Select Process: Add New Note: The program must be driven by list, allow user account, show existing accounts, update specific account, delete account. The program should consist of the following functions:1. The showChoice function: The showChoice function explains options to the user and explains how to enter data.2. addAccount function: the function adds a new account.3. showAccount function: the function shows all accounts.4. searchAccount function: the function updates information for a specific account.5. deleteAccount function: the function of deleting a specific account.6. ExitProg function: This function terminates the execution of the program. Notice. Account information is: account number, customer name. Customer ID. And the city
Chapter 5 Solutions
Problem Solving with C++ (10th Edition)
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
- This is a c++ programming question. Write a header file called apple.h It should contain the following items: - a macro which gets one input parameter and return the square of the input value. - an inline function which gets two float type input parameters and returns the greater value. - a symbolic constant called M which has the value 100.arrow_forwardFor any integer n > 0, n! (n factorial) is defined as the product n * n - 1 * n - 2 . * 2 * 1. And 0! is defined to be 1. It is sometimes useful to have a closed-form definition instead; for this purpose, an approximation can be used. R.W. Gosper proposed the following approximation formula: n! - n"e", 2n + 3 a) Create a prompt that takes in n as input. b) Compute n! accurately and store the results in an appropriate variable. n! = n * (n - 1) * (n - 2) 2 * 1. c) Next, compute n! using the approximation formula and store the results in appropriate variables. d) The message displaying the result should look something like this: 5! equals approximately 119.97003 5! is 120 accurately. e) Test the program on nonnegative integers less than 10. (A type int might not accommodate overly large numbers so feel free to store the values in an unsigned int data type). Find the difference between the two results for accurateness, then compute the percent error. Is the approximation a good…arrow_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_forward
- #include <stdio.h> // Do not edit these directives or add another.#include <stdlib.h>#include <string.h>#include <time.h> #define MAX 1000 // Do not edit this macro. typedef struct // Do not edit this struct.{unsigned long restaurant_id;char restaurant_name[15];char description[127];double rate;char cuisine[31];unsigned short opening_year;unsigned long capacity;char city[31];char address[63];char owner[31];} RECORD_t, *RECORD; /* DECLARE YOUR FUNCTION PROTOTYPES HERE. */void find_by_opening_year(unsigned short opening_year, RECORD *restaurant_array, unsigned long size, unsigned long start, unsigned long end, unsigned long *p_found_num, RECORD **p_found_restaurants);RECORD find_by_restaurant_name(char *restaurant_name, RECORD *restaurant_array, unsigned long size, unsigned long start, unsigned long end);unsigned long insert(RECORD restaurant, RECORD *restaurant_array, unsigned long *p_size);RECORD delete (unsigned long restaurant_id, RECORD *restaurant_array,…arrow_forward#include <stdio.h> // Do not edit these directives or add another. #include <stdlib.h> #include <string.h> #include <time.h> #define MAX 1000 // Do not edit this macro. typedef struct // Do not edit this struct. { unsigned long restaurant_id; char restaurant_name[15]; char description[127]; double rate; char cuisine[31]; unsigned short opening_year; unsigned long capacity; char city[31]; char address[63]; char owner[31]; } RECORD_t, *RECORD; /* DECLARE YOUR FUNCTION PROTOTYPES HERE. */ void find_by_opening_year(unsigned short opening_year, RECORD *restaurant_array, unsigned long size, unsigned long start, unsigned long end, unsigned long *p_found_num, RECORD **p_found_restaurants); RECORD find_by_restaurant_name(char *restaurant_name, RECORD *restaurant_array, unsigned long size, unsigned long start, unsigned long end); unsigned long insert(RECORD restaurant, RECORD *restaurant_array, unsigned long *p_size); RECORD delete (unsigned long restaurant_id, RECORD…arrow_forwardpython" You have an Internet connection with a download speed of 41 Megabits per second (Mbps) and you want to calculate how long it will take to download a files based on their size. Write a function named "download_time" that takes an integer as a parameter. The parameter represents the size of a file in Gigabytes that you want to download. The function should return the number of seconds it will take to download that file if your download speed is 41 Megabits per second. To convert the file size from Gigabytes to Megabits remember that 1 Gigabyte equals 1000 Megabytes and that 1 Megabyte equals 8 Megabits.arrow_forward
- C++A new video store in your neighborhood is about to open. However, it does not have a program to keep track of its videos and customers. The store managers want someone to write a program for their system so that the video store can operate. The program will require you to design 2 ADTs as described below: [1] VIDEO ADT Data Operations Video_ID (preferably int, auto-generated) Movie Title Genre Production Number of Copies Movie Image Filename [1] Insert a new video [2] Rent a video; that is, check out a video [3] Return a video, or check in, a video [4] Show the details of a particular video [5] Display all videos in the store [6] Check whether a particular video is in the store [2] CUSTOMER PARENT ADT Data Operations Customer_ID (preferably int, auto-generated) Name Address [1] Add Customer [2] Show the customer details [3] Print list of all customers [3] CUSTOMER-RENT CHILD ADT Customer_ID ( Video_ID (of all rented videos of a…arrow_forwardSelect the statements that apply to local variables. Only statements within subroutine can view or modify local variables. Storage used by local variables is released when subroutine ends. Local variable name cannot have the same name as a local variable in another function.arrow_forwardI'd like a BCR code using c ++ structures and files. Age Project -8 Using structures and files: Create a C ++ program for the bank records system.Select Process: Add New Note: The program must be driven by list, allow user account, show existing accounts, update specific account, delete account. The program should consist of the following functions:1. The showChoice function: The showChoice function explains options to the user and explains how to enter data.2. addAccount function: the function adds a new account.3. showAccount function: the function shows all accounts.4. searchAccount function: the function updates information for a specific account.5. deleteAccount function: the function of deleting a specific account.6. ExitProg function: This function terminates the execution of the program. Notice. Account information is: account number, customer name. Customer ID. And the cityarrow_forward
- You need to write a program in C that will allow a teacher to store, update and view the grades of multiple students. The program should perform the following operations: Add a new student and their grades for different subjects. View the grades of a particular student. Update the grades of a particular student. View the average grades of all students.The program should store the following information for each student: Student name (string) Roll number (integer) Grades for 5 subjects (integers)The program should implement a menu-driven interface for the user to perform the above operations. The program should continue to run until the user selects to exit.Constraints: The student name should not exceed 50 characters. The roll number should be a positive integer and should be unique for each student. The grades should be integers in the range [0, 100].arrow_forwardInstructions: You are strictly not allowed to use anything other than pointers and dynamic memory. One function should perform one functionality only. Task 1 Write a program in C++ that reads data from a file. Create dynamic memory according to the data. Now your task is to perform the following task. Row wise Sum Column wise Sum Diagonal wise Sum Example data.txt 4 5 1.6 10.2 33.7 99 20.5 3 44 50 96.1 2 8 9 4 74 50 99 19.1 Output: Sum row wise: 165, 191, 17, 242.1 Sum col wise: 127.6, 120.1, 228.8, 118.1, 20.5 Sum diagonal wise: Not Possible Note: You are restricted to use pointers and your function should be generic. Avoid memory wastage, memory leakage, dangling pointer. Use regrow or shrink concepts if required.arrow_forwardA function named power has already been defined. It consumes two int arguments and returns the int which is the first argument value raised to the second argument value. Assume a variable named side_length has already been assigned an int value. Write a statement which uses the function power to compute the volume of a cube where each side is of length side_length, and assign that value to a variable volume.(use Python)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education