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
thumb_up100%
Chapter 9, Problem 5PP
Program Plan Intro
- Include header files and declare the required namespaces.
- Initialize the main function.
- Prompt the user to enter the sequence of the character to be replaced.
- Compare the result and display the output.
Program Description: The purpose of the program is to enter the sequence of character to be replaced and substitute the string and then finally display the modified string.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
1. (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;
}
(Python)Write a function that receives an integer. The function must return a string containing thehexadecimal representation of the integer.
(Python)
Without giving me the code, can you give me some advice or tips on approaching this?
Chapter 9 Solutions
C++ for Engineers and Scientists
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- (Rounding Numbers) Function floor can be used to round a number to a specific decimal place. The statementy = floor(x * 10 + 0.5) / 10;rounds x to the tenths position (the first position to the right of the decimal point). The statementy = floor(x * 100 + 0.5) / 100;rounds x to the hundredths position (the second position to the right of the decimal point). Write a program that defines fourfunctions to round a number x in various ways:A. roundToInteger(number)B. roundToTenths(number)C. roundToHundredths(number)D. roundToThousandths(number)For each value read, your program should print the original value, the number rounded to the nearest integer, the number rounded to the nearest tenth, the number rounded to the nearest hundredth and the number rounded to the nearest thousandth.arrow_forward(Perfect Numbers) An integer number is said to be a perfect number if its factors, including1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6 =1 + 2 + 3. Write a function isPerfect that determines whether parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1and 1000. Print the factors of each perfect number to confirm that the number is indeed perfect.Challenge the power of your computer by testing numbers much larger than 1000.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
- (IN PYTHON) Problem 2 Write a function count_8s(string) that performs the following actions: Receives a single parameter called string that we expect to be a string. If we receive something that is NOT a string, raise a TypeError with the message “Non-string input received.” Uses recursion to count the number of eights in the string. Use a string of length 0 as your base case. Otherwise, determine if the first character in string is “8” or not, and call count_8s() again with the rest of the string as an argument. Returns the number of eights found in the string. NOTE: You are not to use a while or for loop in your code.arrow_forward(Rounding Numbers) Function floor may be used to round a number to a specific decimalplace. The statementy = floor(x * 10 + .5) / 10;rounds x to the tenths position (the first position to the right of the decimal point). The statementy = floor(x * 100 + .5) / 100;rounds x to the hundredths position (the second position to the right of the decimal point). Writea program that defines four functions to round a number x in various waysa) roundToInteger(number)b) roundToTenths(number)c) roundToHundreths(number)d) roundToThousandths(number)For each value read, your program should print the original value, the number rounded to thenearest integer, the number rounded to the nearest tenth, the number rounded to the nearest hundredth, and the number rounded to the nearest thousandth.arrow_forward[THIS IS NOT GRADED] The question mentions the bouncy program; this is the bouncy program I have written that computes the total distance traveled by the ball given initial height, bounciness index, and number of bounces: height = float(input("Enter the height from which the ball is dropped: ")) bounciness = float(input("Enter the bounciness index of the ball: ")) distance = 0 bounces = int(input("Enter the number of times the ball is allowed to continue bouncing: ")) for eachPass in range(bounces): distance += height height *= bounciness distance += height print('\nTotal distance traveled is:', distance, 'units.') I will attatch the pre-existing code that the question provided. Thank you for your help.arrow_forward
- (Square of Asterisks) Write a function that displays a solid square of asterisks whose side isspecified in integer parameter side. For example, if side is 4, the function displays: **** **** **** ****arrow_forward(Display patterns using loops) Use nested loops that display the following patterns in two separateprograms: pattern A Pattern B Pattern c 123456 1 3 1 6 1 2 3 3 3 1 6 1 2 3 4 5 3 3 3 1 6 1 2 3 4 5 6 7 3 3 1 6 1 2 3 4 5 6 7 8 9 3 123456arrow_forward(Use python):The instructor of a lower division statistics class has assigned you a task: make a function that takes in a student’s score on a scale from 0 to 100 and assigns a letter grade based on the following grade boundaries.arrow_forward
- (Computer-Assisted Instruction: Reducing Student Fatigue) One problem in CAI environments is student fatigue. This can be reduced by varying the computer’s responses to hold the student’s attention. Modify the program of Exercise 6.57 so that various comments are displayed for each answer as follows: Possible responses to a correct answer: Very good!Excellent!Nice work!Keep up the good work! Possible responses to an incorrect answer: No. Please try again.Wrong. Try once more.Don't give up!No. Keep trying.Use random-number generation to choose a number from 1 to 4 that will be used to select one of the four appropriate responses to each correct or incorrect answer. Use a switch statement to issue the responses. ------------------------------ EXERCISE 6.57 CODE: ----------------------------- //Name: IhabAtouf//Date:02/23/2023// exercise 6.57 on page 281//program description: create computer-assisted instruction (CAI) program that help students master thier math skills in…arrow_forward(Python) Write a function that receives a string containing a 32-bit hexadecimal integer. The functionmust return the string’s integer value.arrow_forward(Format an integer) Write a function with the following header to format the inte- ger with the specified width. def format(number, width): The function returns a string for the number with prefix 0s. The size of the string is the width. For example, format(34, 4) returns "0034" and format(34, 5) returns "00034". If the number is longer than the width, the function returns the string representation for the number. For example, format(34, 1) returns "34". Write a test program that prompts the user to enter a number and its width and dis- plays a string returned from invoking format(number, width). Here is a sample run: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
Boolean Algebra - Digital Logic and Logic Families - Industrial Electronics; Author: Ekeeda;https://www.youtube.com/watch?v=u7XnJos-_Hs;License: Standard YouTube License, CC-BY
Boolean Algebra 1 – The Laws of Boolean Algebra; Author: Computer Science;https://www.youtube.com/watch?v=EPJf4owqwdA;License: Standard Youtube License