C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 12SA
Program Plan Intro
To provide the output of the given program.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Please do the following and show execution code and output!
Write two Haskell functions to calculate ticket prices. Tickets for those ages 12 and under are $8.50, tickets for those between 13 and 65 are $14.50 and those older than 65 are $9.00. The second function should calculate tax – assume tax is 12%. Using function chaining to calculate the total cost. The main function should ask what type of ticket the person wants (child, adult, or senior) and call the functions that you wrote. Show the type signatures of the functions you write.
c++
the following function header is for a function thattakes two pointers to double-precision, floatingpoint numbers x and y as parameters and does notreturn a value.void exchange( double *x, double y )
Select one:
True
False
I need help in creating 5 user defined function in C to solve the following problem as shown in the screenshot. Below is the skeleton code for the problem. The 5 user defined functions need to be created in accordance to the screenshot and should be tested in the int main function.
The Skeleton Code
#include <stdio.h>#include <string.h>
typedef char String30[31];typedef char String60[61];
/* TO DO: Implement the functions as specified in screenshot above RESTRICTIONS: 1. Do NOT call printf() or scanf() in any of the required function definition EXCEPT in the main() function. */
/* Step 1: Define the function that will achieve this step right after this comment. Do NOT call print(), scanf() and any other library functions not indicated above.
User defined function has to be made in accordance to step 1 in the screenshot
*/
/* Step 2: Define the function that will achieve this step right after this comment. Do…
Chapter 4 Solutions
C++ Programming: From Problem Analysis to Program Design
Ch. 4 - Prob. 1TFCh. 4 - Prob. 6SACh. 4 - Prob. 12SACh. 4 - Write a program that prompts the user to input a...Ch. 4 - Write a program that prompts the user to output an...Ch. 4 - Prob. 4PECh. 4 - In a right triangle, the square of the length of...Ch. 4 - Write a program that mimics a calculator. The...Ch. 4 - Redo Exercise 8 to handle floating-point numbers....Ch. 4 - The number of lines that can be printed on a paper...
Ch. 4 - The short-term, 0-24 hours, parking fee, F, at an...Ch. 4 - Write a program to implement the algorithm that...Ch. 4 - Samantha and Vikas are looking to by a house in a...Ch. 4 - One way to determine how healthy a person is by...Ch. 4 - Ron bought several acres of farm to grow and sell...Ch. 4 - The cost of renting a room at a hotel is, say...Ch. 4 - Let l be a line in the x-y plane. If l is a...Ch. 4 - The first 11 prime integers are 2, 3, 5, 7, 11,...
Knowledge Booster
Similar questions
- In C++ Please Modify the program 8-31 from page 584, 585 by adding the following: 1. Add a prototype before main() like: void bubbleSort(Circle [], int); 2. On line 21 add the following function call: bubbleSort(circle, SIZE); 3. After main() function add the definition for bublleSort() function similar to the one on page 628. Evidently you must change the Inventory data type with Circle. The example in the textbook displays all the areas in order because the input is such that will cause the in order output. Your program should display all circles in order even when the input for radii is not in any particular order. // This program uses an array of objects. // The objects are instances of the Circle class. #include <iostream> #include <iomanip> #include "Circle.h" // Circle class declaration file using namespace std; const int NUM_CIRCLES = 4; int main() { Circle circle[NUM_CIRCLES]; // Define an array of Circle objects // Use a loop to initialize the radius of each…arrow_forwardC programming Q1) Write a function called letter grade that has a type int input parameter called points andreturns through an output parameters gradepLetter and gradepNumber. The appropriate lettergrade matching is given in the table below. Return through a second output parameter(just_missedp) an indication of whether the student just missed the next higher grade (true for89, 79, 64 and so on).Prototype: void letter_grade(int points, char *gradepLetter, char*gradepNumber, char *just_missedp);arrow_forwardYou are assigned to develop a C++ Program using Classes, Functions, Arrays and Pointers that requires users to enter their own passwords. Your software requires that user’s passwords meet the following criteria: The password should be at least sixteen (16) characters long. The password should contain at least: one uppercase letter one lowercase letter one digit one special character (no spaces) Write a program that asks for a password and then verifies that it meets the stated criteria. If it doesn’t, the program should display a message telling the user why. Whenever possible, use pointers. Manually destroy any memory used when finished using it.arrow_forward
- Implement C Programming 7.6.1: LAB: Simple car Given two integers that represent the miles to drive forward and the miles to drive in reverse as user inputs, create a SimpleCar variable that performs the following operations: Drives input number of miles forward Drives input number of miles in reverse Honks the horn Reports car status SimpleCar.h contains the struct definition and related function declarations. SimpleCar.c contains related function definitions. Ex: If the input is: 100 4 the output is: beep beep Car has driven: 96 miles #include <stdio.h> #include "SimpleCar.h" int main() { /* Type your code here. */ return 0;}arrow_forwardImplement C Programming 7.7.1: LAB: Vending machine Given two integers as user inputs that represent the number of drinks to buy and the number of bottles to restock, create a VendingMachine variable that performs the following operations: Purchases input number of drinks Restocks input number of bottles Reports inventory VendingMachine.h contains the struct definition and related function declarations. VendingMachine.c contains related function definitions. A VendingMachine's initial inventory is 20 drinks. Ex: If the input is: 5 2 the output is: Inventory: 17 bottles #include <stdio.h> #include "VendingMachine.h" int main() { /* Type your code here. */ return 0;}arrow_forwardQ13/ Write a program in c++ that asks the user to input two numbers. If the first number entered is greater than the second number, the program should print the message: "The first number is greater." Otherwise, it should print the message: "The first number is smaller." .By using functionsarrow_forward
- 1. Write a program in python that contains a main function and a custom, void function named show_larger that takes two random integers as parameters. This function should display which integer is larger and by how much. The difference must be expressed as a positive number if the random integers differ. If the random integers are the same, show_larger should handle that, too. See example outputs. In the main function, generate two random integers both in the range from 1 to 5 inclusive, and call show_larger with the integers as arguments.EXAMPLE OUTPUT 13 is larger than 1 by 2EXAMPLE OUTPUT 2The integers are equal, both are 3arrow_forwardQuestion 1 is already done need help with the others though This is the C code I have so far #include <stdio.h> #include <stdlib.h> struct employees { char name[20]; int ssn[9]; int yearBorn, salary; }; struct employees **emps = new employees()[10]; //Added new statement ---- bartleby // function to read the employee data from the user void readEmployee(struct employees *emp) { printf("Enter name: "); gets(emp->name); printf("Enter ssn: "); for(int i =0; i <9; i++) scanf("%d", &emp->ssn[i]); printf("Enter birth year: "); scanf("%d", &emp->yearBorn); printf("Enter salary: "); scanf("%d", &emp->salary); } // function to create a pointer of employee type struct employees *createEmployee() { // creating the pointer struct employees *emp = malloc(sizeof(struct employees)); // function to read the data readEmployee(emp); // returning the data return emp; } // function to…arrow_forwardPlease help me explain the following void function c++ code, which I did not understand. Especially for the first void function and int main(), I do not understand why the first void function enter the number and the int main function print out the final answer. #include <iostream>using namespace std; void getNumber(int *input); void doubleValue(int *val); int main(){ int number; getNumber(&number); doubleValue(&number); cout<<"That value doubled is"<<number<<endl; return 0;}void getNumber(int *input){ cout<<"Enter an integer number:"; cin>>*input; }void doubleValue(int *val){ *val *=2;}arrow_forward
- Engineers often measure the ratio of two power measurements in decibels, or dB, which can be calculated as follows:dB= log10P2/P1Where P2 is the power level being measured, and P1 is some reference power level. Write a c++ programe contain function that calculates the level. The function’s prototype is as follows:double dBCalculator (double P1, double P2);Then, call dBCalculator from the main function to find the power ratio for the measurements from 1 to 20 Watts, in 2 Watt steps. You can assume that the reference power P1 is 1 Watt.arrow_forwardMark the following statements as true or false: a. To use a predefined function in a program, you need to know only the name of the function and how to use it. (1) b. A value-returning function returns only one value. (2, 3) c. Parameters allow you to use different values each time the function is called. (2, 7, 9) d. When a return statement executes in a user-defined function, the function immediately exits. (3, 4) e. A value-returning function returns only integer values. (4) f. A variable name cannot be passed to a value parameter. (3, 6) g. If a C++ function does not use parameters, parentheses around the empty parameter list are still required. (2, 3, 6) h. In C + + , the names of the corresponding formal and actual parameters must be the same. (3, 4, 6) i. A function that changes the value of a reference parameter also changes the value of the actual parameter. (7) j. Whenever the value of a reference parameter changes, the value of the actual parameter changes. (7) k. In C++, function definitions can be nested; that is, the definition of one function can be enclosed in the body of another function. (9) l. Using global variables in a program is a better programming style than using local variables, because extra variables can be avoided. (10) m. In a program, global constants are as dangerous as global variables. (10) n. The memory for a static variable remains allocated between function calls. (11)arrow_forwardImplement in C Programming 7.6.1: LAB: Simple car Given two integers that represent the miles to drive forward and the miles to drive in reverse as user inputs, create a SimpleCar variable that performs the following operations: Drives input number of miles forward Drives input number of miles in reverse Honks the horn Reports car status SimpleCar.h contains the struct definition and related function declarations. SimpleCar.c contains related function definitions. Ex: If the input is: 100 4 the output is: beep beep Car has driven: 96 miles main.c #include <stdio.h> #include "SimpleCar.h" int main() { /* Type your code here. */ return 0;} SimpleCar.h #ifndef SIMPLE_CAR_H#define SIMPLE_CAR_H typedef struct SimpleCar_struct { int miles;} SimpleCar; SimpleCar InitCar();SimpleCar Drive(int dist, SimpleCar car);SimpleCar Reverse(int dist, SimpleCar car);int GetOdometer(SimpleCar car);void HonkHorn(SimpleCar car);void Report(SimpleCar car); #endif SimpleCar.c #include…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning