MYPROGRAMMINGLAB WITH PEARSON ETEXT
8th Edition
ISBN: 9780134225340
Author: Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 5, Problem 5.17E
Program Plan Intro
Program Plan-
- Include the header files and initialize the main() function.
- Declare the function prototypes for multiple() function.
- Declare a variable for taking the two numbers.
- Call the function to display whether the second number is the multiple of the first number or not.
- Define the function role in the respective function definition.
Program description:
The program defines function isMultiple which takes a pair of integers as arguments and finds if the second is multiple of first. The program then uses this function in main function to test a series of pair of integers.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(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.
(Rounding Numbers) Function floor may be
used to round a number to a specific decimal
place. The statement y = floor(x * 10 + .5) / 10;
rounds x to the tenths position (the first
position to the right of the decimal point). The
statement y = floor(x * 100 + .5) / 100; rounds x
to the hundredths position (the second position
to the right of the decimal point). Write a
program that defines four functions to round a
number x in various ways a)
roundTolnteger(number) b)
roundToTenths(number) c)
roundToHundreths(number) d)
roundToThousandths(number) For each value
%3D
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 hun-
dredth, and the number rounded to the nearest
thousandth. IN C PROGRAMMING LANGUAGE
PLEASE
(Rounding Numbers) Function floor may be used to round a number to a specific decimal place. The statement
y = floor(x * 10 + .5) / 10;
rounds x to the tenths position (the first position to the right of the decimal point). The statement
y = floor(x * 100 + .5) / 100;
rounds x to the hundredths position (the second position to the right of the decimal point). Write a program that defines four functions to round a number x in various ways
a) 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 the nearest integer, the number rounded to the nearest tenth, the number rounded to the nearest hun- dredth, and the number rounded to the nearest thousandth.
IN C PROGRAMMING LANGUAGE PLEASE
Chapter 5 Solutions
MYPROGRAMMINGLAB WITH PEARSON ETEXT
Ch. 5 - Show the value of x after each of the following...Ch. 5 - (Parking Charges) A parking garage charges a $2.00...Ch. 5 - (Rounding Numbers) An application of function...Ch. 5 - (Rounding Numbers) Function floor may be used to...Ch. 5 - Write statements that assign random integers to...Ch. 5 - For each of the following sets of integers, write...Ch. 5 - (Hypotenuse Calculations) Define a function called...Ch. 5 - (Exponentiation) Write a function...Ch. 5 - Prob. 5.17ECh. 5 - Prob. 5.18E
Ch. 5 - Prob. 5.19ECh. 5 - (Displaying a Square of Any Character) Modify the...Ch. 5 - Prob. 5.21ECh. 5 - (Separating Digits) Write program segments that...Ch. 5 - (Time in Seconds) Write a function that takes the...Ch. 5 - (Temperature Conversions) Implement the following...Ch. 5 - (Find the Minimum) Write a function that returns...Ch. 5 - (Perfect Numbers) An integer number is said to be...Ch. 5 - Prob. 5.27ECh. 5 - (Reversing Digits) Write a function that takes an...Ch. 5 - (Greatest Common Divisor) The greatest common...Ch. 5 - (Quality Points for Students Grades) Write a...Ch. 5 - (Coin Tossing) Write a program that simulates coin...Ch. 5 - (Guess the Number) Write a C program that plays...Ch. 5 - (Guess the Number Modification) Modify the program...Ch. 5 - (Recursive Exponentiation) Write a recursive...Ch. 5 - (Fibonacci) The Fibonacci series 0, 1, 1, 2, 3, 5,...Ch. 5 - (Towers of Hanoi) Every budding computer scientist...Ch. 5 - Prob. 5.37ECh. 5 - Prob. 5.38ECh. 5 - Prob. 5.39ECh. 5 - Prob. 5.40ECh. 5 - (Distance Between Points) Write a function...Ch. 5 - Prob. 5.42ECh. 5 - Prob. 5.43ECh. 5 - After you determine what the program of Exercise...Ch. 5 - (Testing Math Library Functions) Write a program...Ch. 5 - Find the error in each of the following program...Ch. 5 - Prob. 5.47ECh. 5 - (Research Project: 1m proving the Recursive...Ch. 5 - (Global Warming Facts Quiz) The controversial...Ch. 5 - Prob. 5.50MDCh. 5 - Prob. 5.51MDCh. 5 - (Computer-Assisted Instruction: Monitoring Student...Ch. 5 - (Computer-Assisted Instruction: Difficulty Levels)...Ch. 5 - (Computer-Assisted Instruction: Varying the Types...
Knowledge Booster
Similar questions
- (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(Use Python) The function course_average should calculate and return the average of the three values pass to it. The function main should ask the user to enter three grades and then pass these values to the course_average function. This function should also display a message to the user in the format below. For example, if the user entered 100, 90 and 95 the message would be:The average of 100 , 90 and 95 is 95arrow_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
- (Use Python) Use the Design Recipe to write a function called which_day that consumes an int representing the number of days that have passed since Friday and returns name of the current day of the week. For example, if 2 days have passed, then ‘Sunday’ should be returned. Include a docstring! For example: Test Result 2 Sunday 4 Tuesday 6 Thursday 8 Saturday 10 Monday Write 3 assert_equal statements to test your function.arrow_forward(Hypotenuse) Define a function hypotenuse that calculates the length of the hypotenuse of a right triangle when the other two sides are given. Use this function in a program to determine the length of the hypotenuse for each of the triangles shown below. The function should take two double arguments and return the hypotenuse as a double. Sample output Enter 2 sides of right triangle: 3.0 4.0 Hypotenuse: 5.0 Enter 2 sides of right triangle: 5.0 12.0 Hypotenuse: 13.0 Enter 2 sides of right triangle: 8.0 15.0 Hypotenuse: 17.0arrow_forward(Single Digit) Complete the definition of the following function:singleDigit :: Int -> Int singleDigit takes a positive integer, num, as input and returns a digit between 0 and 9 as the output. The output is computed as follows: sum all the digits in num to obtain a result; if this result is less than 10 then result is the answer; otherwise take the result and apply the same procedure (i.e. sum its digits and compute a result, and so on). Here is a sample run:*Main> singleDigit 37425 3 *Main> singleDigit 9876543 6 Here is how the above answers are computed by hand:singleDigit 37425 => 3+7+4+2+5 = 21 => 2+1 = 3 singleDigit 9876543 => 9+8+7+6+5+4+3 = 42 => 4+2 = 6arrow_forward
- (a) Write the following functions and their docstrings: • between (num1, num2, num3) takes 3 integer arguments and returns True if num2 is between num1 and num3. It is not between them if it is equal to either of the other two. For example, given the inputs 5, 3 and 0, the value returned should be True. Given the inputs -2, 2 and 2, False should be returned. Note that there is no restriction that num1 must be less than num3. • majorityEven (num_list) returns True if more than half of the integers in the num_list are di- visible by 2, with no remainder, otherwise it returns False. The list can be of any size. Recall that zero is divisible by 2 with no remainder. For example, the function should return False for the list [1,2,3,6] (as only two of the four numbers are divisible by 2) and True for the list [0,1,-4] (as two of the three numbers are divisible by 2). (b) Generate at least six test cases for each function you wrote in part (a). You may use white-box and/or black-box test case…arrow_forward(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_forward(Exponentiation) Write a function integerPower(base, exponent) that returns the value ofbaseexponentFor example, integerPower(3, 4) = 3 * 3 * 3 * 3. Assume that exponent is a positive, nonzero integer, and base is an integer. Function integerPower should use for to control the calculation. Donot use any math library functions.arrow_forward
- (python) Speed of Sound is a constant 343 m/s Create a function that will return the Frequency Heard based on the above equation. The function should accept the following parameters: speed of sound, velocity of receiver, velocity of source and frequency of source. Make sure to prompt the user for the input data and call the function. Example Values/Results: Frequency of Source: 935 HzVelocity of receiver: 24 m/sVelocity of source 43 m/sHeard frequency is 888.977 Hzarrow_forward(Variable-Length Argument List: Calculating Products) Write a program that calculates theproduct of a series of integers that are passed to function product using a variable-length argumentlist. Test your function with several calls, each with a different number of arguments.arrow_forward(Displaying a Square of Any Character) Modify the function created in Exercise 5.19 toform the square out of whatever character is contained in character parameter fillCharacter. Thusif side is 5 and fillCharacter is “#”, then this function should print: ##### ##### ##### ##### #####arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning