C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Question
Chapter 6.1, Problem 12E
(a)
Program Plan Intro
To write the template of a function named display(). This function has one argument. This function displays the value of the argument passed to the function when it is called.
(b)
Program Plan Intro
Program Plan:
- valuevariable is used in the program.
- display() function is include in the program to compute and return the square of a number.
Program Description: The main purpose of the program is to include the function named display() in the main program. Call the function from the main () function. Test the function named display() by passing the values.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(C++) Write a function definition called quotient that takes as its parameters two decimal values,
numer and denom, to divide. Remember that division by 0 is not allowed. If division by 0 occurs,
display the message "NaN" to the console, otherwise display the result of the division and its
remainder.
(C program only)
2: Return structure from a function
Create a function that will get information of students using structure. When the function is called it will return a structure. The returned structure is displayed from the main() function.
Input
1. name
Constraints
accept string until \n is encountered
2. age
Constraints
The input must be an integer value
Output
Enter student name: Juan deal CruzEnter age: 18
Displaying Information:Name: Juan dela CruzAge: 18
(C PROGRAMMING ONLY)
2. Weird Treasure Chestby CodeChum Admin
I'm now in the middle of the jungle when I saw this weird treasure chest.
It seems that if I properly place the address of a certain number, I get a very weird result!
Instructions:
In the code editor, you are provided with a treasureChestMagic() function which has the following description:Return type - voidName - treasureChestMagicParameters - an address of an integerDescription - updates the value of a certain integer randomlyYou do not have to worry about how the treasureChestMagic() function works. All you have to do is ask the user for an integer and then call the treasureChestMagic() function, passing the address of that integer you just asked.Finally, print the updated value of the integer inputted by the user.Input
1. An integer
Output
Enter n: 10Treasure Chest Magic Result = 13
Chapter 6 Solutions
C++ for Engineers and Scientists
Ch. 6.1 - (Practice) For the following function headers,...Ch. 6.1 - Prob. 2ECh. 6.1 - Prob. 3ECh. 6.1 - (Statics) A beam’s second moment of inertia, also...Ch. 6.1 - (Statics) An annulus is a cylindrical rod with a...Ch. 6.1 - Prob. 6ECh. 6.1 - (Physics) Buoyancy is the upward force a liquid...Ch. 6.1 - (Numerical) a. Write a C++ program that accepts an...Ch. 6.1 - (Practice) a. Write a function that produces a...Ch. 6.1 - Prob. 10E
Ch. 6.1 - Prob. 11ECh. 6.1 - Prob. 12ECh. 6.1 - Prob. 13ECh. 6.1 - Prob. 14ECh. 6.1 - Prob. 15ECh. 6.2 - Prob. 1ECh. 6.2 - (Practice) For the following function headers,...Ch. 6.2 - (General math) a. Write a function named...Ch. 6.2 - (General math) a. The volume, V, of a cylinder is...Ch. 6.2 - Prob. 6ECh. 6.2 - Prob. 10ECh. 6.2 - (Numerical) a. The following is an extremely...Ch. 6.2 - Prob. 12ECh. 6.2 - Prob. 13ECh. 6.3 - Prob. 2ECh. 6.3 - Prob. 4ECh. 6.3 - Prob. 5ECh. 6.4 - (Practice) The volume, v, and side surface area,...Ch. 6.4 - (Practice) Write a C++ program that accepts the...Ch. 6.4 - (Simulation) Write a program to simulate the roll...Ch. 6.4 - (Numerical) Write a program that tests the...Ch. 6 - Prob. 1PPCh. 6 - Prob. 2PPCh. 6 - Prob. 6PPCh. 6 - (Numerical) Heron’s formula for the area, A, of a...Ch. 6 - Prob. 10PP
Knowledge Booster
Similar questions
- (Q3) This is a Data Structures problem and the programming language used is Lisp. Solve the question we detailed steps and make it concise and easy to understand. Please and thank you.arrow_forward1. (Dice simulation) Java/C++ program that computes the exact probability distribution for the sum of two dice. Run experiments to validate this calculation simulating N dice throws, keeping track of the frequencies of occurrence of each value when you compute the sum of two random integers between 1 and 6. How large does N have to be before your empirical results match the exact results to three decimal places?arrow_forward(Signal Handling) Read the documentation for your compiler to determine what signals are supported by the signal-handling library (). Write a program that contains signal handlers for the standard signals SIGABRT and SIGINT. The program should test the trapping of these signals by calling function abort to generate a signal of type SIGABRT and by having the user type c ( C on OS X) to generate a signal of type SIGINT.arrow_forward
- (C++ Programming) You are given a file consisting of students’ names in the following form: lastName, firstName middleName. (Note that some students may not have a middle name.) Write a program that converts each name to the following form: firstName middleName lastName. Your program must read each student’s entire name into a variable and must contain a function that takes as input a string, consisting of a student’s name, and returns a string consisting of the altered name. • Use the string function find to find the index of , • the function length to find the length of the string • the function substr to extract the firstName, middleName and lastName. Output the altered name into a file. This program has no user interface. Banks,John William Barret,Ron Drew,Lucy Marie Perry,Mark G Smith,John Carrarrow_forward(Q2) This is a Data Structures problem and the programming language used is Lisp. Solve the question we detailed steps and make it concise and easy to understand. Please and thank you.arrow_forward7. [10] (Display Pattern) Write a C++ function called pattern that displays a pattern of stars and numbers for a given number of columns (passed as a parameter). Maximize your use of repetition (with nested for statements) and minimize the number of cout statements. Your function should then display a pattern of the appropriate size. Write a test program (main) that generates a random number in the range of 1 to 20 (inclusive) to specify the number of columns in the pattern. Use pattern to display the pattern with this random number as the number of columns. Here are two samples: With 3 as the input: With 5 as the input: 1 1 *2 *2 **3 **3 *2 ***4 1 ****5 ***4 **3 *2 1arrow_forward
- (PYTHON) a) get_total_cases() takes the a 2D-list (similar to database) and an integer x from this set {0, 1, 2} as input parameters. Here, 0 represents Case_Reported_Date, 1 represents Age_Group and 2 represents Client_Gender (these are the fields on the header row, the integer value represents the index of each of these fields on that row). This function computes the total number of reported cases for each instance of x in the text file, and it stores this information in a dictionary in this form {an_instance_of_x : total_case}. Finally, it returns the dictionary and the total number of all reported cases saved in this dictionary. (Suppose we want to know the total number of cases reported on each date, so use x = 0.) >>> result, total_cases = get_total_cases(database, 0) >>> display_dict(result) 2021-05-19: 8 2021-05-20: 2 2021-05-21: 1 2021-05-22: 1 >>> print(total_cases) 12arrow_forward(Valid Password) You are required to test the validity of a password by writing the following 4 C++ functions: a. A function called passSize that receives a string and returns true if the string has 8 or more characters. b. HA function called passSpace that receives a string and returns false if the string has space. A function called passSymbol that receives a string and returns true if the string has at least one symbol (consider a symbol as a character that is neither a letter nor a digit). C. d. A function called passUpper that receives a string and returns true if the string has at least one uppercase letter.arrow_forward(Python) Write the definition of a function named findHighestl), that receives three integer parameters: num1, num2, and num3. Thefunction when called should output the highest of the 3 numbers (declare any necessary variables). The function does not returnany values."* Only submit the code for the function definition (which includes the function return value type, function header, functionparameters, and function body).arrow_forward
- (Based on the C or C++) Tabulate the TWO (2) differences between pass by value and pass by address in function parameter passing.arrow_forward(C++)Write a program that will allow a student to compute for his equivalent semestral grade. The program should ask the user should input his/her first name, last name, middle initial, and student number. After, inputting everything above, the output will clear the current screen and a new screen should open. A sample program that would clear a screen is included below for your reference. On the new screen, the user will then be greeted "Welcome, <firstname>! (i.e. Welcome, Louie!)" The program will then ask for the prelim grade, midterm grade and final grade of the student. The program should only accept grades 100 and below. After getting the three grades, the program should compute for the semestral grade. The computation of the semestral grade is as follows: 30%*PrelimGrade + 30%*midtermgrade + 40%finalgrade After inputting all the grades, the screen should clear again and will proceed to another screen. The new screen should output should output the following (this is…arrow_forward(python) Is the statement true or false? If you give a parameter a default value in the function definition, then that parameter is optional when calling that function.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