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.2, Problem 12E
(a)
Program Plan Intro
Program plan:
- DeclarevariablesintNumberof type int.
Program description:
The main purpose of the function is to accepts argument number and return integer part of the number.
(b)
Program Plan Intro
Program plan:
2. Declaredvariablestest1and test2to test the function.
3. cout statement is used to print statement.
Program description:
To include the function written for (a) in a working program.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(C PROGRAMMING ONLY)
4. Special Exchanging Giftsby CodeChum Admin
It's Christmas time and we're having this exchanging gifts activity!
I want to surprise the receiver of my gift. After he/she receives my gift, I will add an additional P100 bill!
Instructions:
In the code editor, you are provided with a main() function that asks the user for 2 integers. Then, a function call to a function named, exchangeGift() is made and the addresses of the 2 integers are passed.This exchangeGift() function hasn't been implemented yet so this is your task. This has the following description:Return type - voidName - exchangeGiftParameters - 2 addresses of 2 integersDescription - swaps the value of the 2 integers and then adds 100 to the 2nd integer (or 2nd parameter)DO NOT EDIT THE MAINInput
1. First integer
2. Second integer
Output
Enter·integer·1:·10Enter·integer·2:·2020·110
(C PROGRAMMING ONLY)
DO NOT EDIT THE MAIN
7. Special Exchanging Giftsby CodeChum Admin
It's Christmas time and we're having this exchanging gifts activity!
I want to surprise the receiver of my gift. After he/she receives my gift, I will add an additional P100 bill!
Instructions:
In the code editor, you are provided with a main() function that asks the user for 2 integers. Then, a function call to a function named, exchangeGift() is made and the addresses of the 2 integers are passed.This exchangeGift() function hasn't been implemented yet so this is your task. This has the following description:Return type - voidName - exchangeGiftParameters - 2 addresses of 2 integersDescription - swaps the value of the 2 integers and then adds 100 to the 2nd integer (or 2nd parameter)DO NOT EDIT THE MAINInput
1. First integer
2. Second integer
Output
Enter integer 1: 10Enter integer 2: 2020 110
(C PROGRAMMING ONLY)
7. Comparing Charactersby CodeChum Admin
Most, if not all things have numeric values. That goes for characters too. In order to find out which character has a higher value, we have to compare them with each other and display the value of the higher character.
Instructions:
In the code editor, you are provided with a main() function that asks the user for 2 characters, passes these characters to a function call of the getHigherValue() function, and then prints out the ASCII value of the higher character.Your task is to implement the getHigherValue function which has the following details:Return type - intName - getHigherValueParameters - 2 characters to be comparedDescription - the ASCII value of the higher character.Hint: Comparing characters in C is just like comparing integers.DO NOT EDIT ANYTHING IN THE MAINInput
1. First character
2. Second character
Output
Enter first character: aEnter second character: hResult value = 104
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
- (JS)Write a function named "tweets" that takes a string as a parameter. If a message can hold at most 280 characters, calculate the smallest number of messages needed to hold all of the text in the input. The function should return the number it calculated.arrow_forwardC++ program (coding) please with output No hand written and fast answer with explanationarrow_forward1. (Functions with Loop and Branches) Write a C program that uses the function, PrintShampoo Instructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, print "Too few.". Else If more than 4, print "Too many.". Else, print "N: Lather and rinse." for numCycles times, where N is the cycle number, followed by "Done.". End with a new line. [hint: use "for" loop from 1 to numCycles times to get desired display] Example output with input 0: Too few Example output with input 5: Too many Example output with input 4: 1: Lather and rinse. 2: Lather and rinse. 3: Lather and rinse. 4: Lather and rinse. Done. #include /* Your user-defined function goes here */ int main(void) { int user Cycles; scanf("%d", &userCycles); PrintShampoo Instructions (user Cycles); return 0; }arrow_forward
- (use Python)Define a function named get_user_number which has no parameters. When called, it gets a number between 1 and 100 (both inclusive) from the user and returns this value. Any other entries by the user are ignored and another value must be entered until they enter a valid number in this range. You may assume that the user types a valid number. For example: Test Input Result print(get_user_number()) -100 0 67 67arrow_forward(python) Write a function with name sqr that takes one argument, x. Write this function so that it computes the value x2, and returns this value. Ensure that no other output is given.arrow_forward(6 marks) 3. Using functions, develop a full C++ structured program that asks the user for his choics:1 or 2. If the choice is 1, then your program will convert the entered Fahrenh (F°) temperature to Celsius (C°). If the choice is 2, then your program will convert th entered Celsius (C°) temperature to Fahrenheit (F°). use the following functions: - getTemp: read the temperature from the user - getChoice: read the user choice: 1 or 2 NOTE: only 1 or 2 are allowed, if not, then give an error message warning for three times, then exit the whole program with a message if the problem persists. - convertToF: converts Celsius to Fahrenheit Fo= (9/5) * C° + 32 - convertToC: converts Fahrenheit to Celsius C°= (5/9) * (F° - 32)arrow_forward
- ( C PROGRAM ONLY) 1: Passing structure to function Create a c program that will ask the user to input student details using structure. Create a function to display the student details (passing struct as argument). 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 deal CruzAge: 18arrow_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(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: 18arrow_forward
- (Use Python) Use the Design Recipe to write a function bmi_risk which consumes two positive numeric arguments into parameters, bmi and age and returns a string 'Low', 'Medium', or 'High' according to the following table: Under 45 45 or over BMI less than 22 Low Medium BMI 22 or more Medium High For example: Test Result print(bmi_risk(21.5, 44)) Low print(bmi_risk(30, 27)) Medium Include a docstring! Write three assert_equal statements to test your function.arrow_forward(C PROGRAMMING ONLY) 3. From Person to Peopleby CodeChum Admin Now that we have created a Person, it's time to create more Person and this tech universe shall be filled with people! Instructions: In the code editor, you are provided with the definition of a struct Person. This struct needs an integer value for its age and character value for its gender. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter. In the main() function, there's a pre-created array of 5 Persons.Your task is to ask the user for the values of the age and gender of these Persons.Then, once you've set their ages and genders, call the displayPerson() function and pass them one by one.Input 1. A series of ages and genders of the 5 Persons Output Person #1Enter Person's age: 24Enter Person's gender: M Person #2Enter Person's·age: 21Enter Person's gender: F Person #3Enter Person's age: 22Enter Person's gender: F Person #4Enter Person's age: 60Enter…arrow_forward2. (Functions with C string parameters) Write a program in C that uses the function, MakeSentenceExcited() to replace any period (full stop or comma) with an exclamation point. If the input string is: I told my computer I needed a break. It replied "I am sorry, I'm not programmed for that function." The output will be: I told my computer I needed a break! It replied "I am sorry! I'm not programmed for that function!" Assign a string size of 200 or above. Use "fgets()" to take the string input. Don't forget to include the string header file. Hint: A very similar example 3 problem is given in the lab slide. Try to follow that example.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