Computer Science: A Structured Programming Approach Using C, Third Edition
3rd Edition
ISBN: 9780534491321
Author: Behrouz A. Forouzan, Richard F. Gilberg
Publisher: Course Technology, Inc.
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 4, Problem 37PS
Write a function that receives a positive floating-point number and rounds it to two decimal places. For example, 127.565031 rounds to 127.570000.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a function that takes a number and returns the largest digit value in the number. For example, given 34567 the function returns 7, and given 28634 it returns 8. """
Write a function timestable(n), which prints a multiplication table of size n. For example,
timestable(5) would print:
1 2 3 4 5
2 3 4 5
4 6 8 10
6 9 12 158 12 16 2010 15 20 25Use the function in a program where you ask the user for n and you print the corresponding table.
Write a function that keeps computing the sum of the digits of x^n, until there is only one digit left. For example, sumOfDigits(2,5) returns 5, because 2 ^ 5 = 32 = 3 + 2 = 5 Another example, sumOfDigits(2,8) returns 4, because 2 ^ 8 = 128 = 1 + 2 + 8 = 13 = 1 + 3 = 4
Chapter 4 Solutions
Computer Science: A Structured Programming Approach Using C, Third Edition
Ch. 4 - Prob. 1PSCh. 4 - The function definition contains the code for a...Ch. 4 - Function calls that return void may not be used as...Ch. 4 - The address operator (&) is used to tell the...Ch. 4 - Variables defined within a block have global...Ch. 4 - Prob. 6PSCh. 4 - Which of the following statements about function...Ch. 4 - Which of the following is not a part of a function...Ch. 4 - Which of the following statements about function...Ch. 4 - Which of the following statements about local...
Ch. 4 - Prob. 11PSCh. 4 - Prob. 12PSCh. 4 - Which of the following statements will generate a...Ch. 4 - Which of the following statements about structure...Ch. 4 - Find any errors in the following function...Ch. 4 - Find any errors in the following function...Ch. 4 - Find any errors in the following function...Ch. 4 - Find any errors in the following function...Ch. 4 - Find any errors in the following function...Ch. 4 - Find any errors in the following function calls:...Ch. 4 - Evaluate the value of the following expressions:...Ch. 4 - Evaluate the value of the following...Ch. 4 - Prob. 23PSCh. 4 - Define the range of the random numbers generated...Ch. 4 - What would be printed from Program 4-17 when run...Ch. 4 - Prob. 26PSCh. 4 - Prob. 27PSCh. 4 - Prob. 28PSCh. 4 - Prob. 29PSCh. 4 - Write a program that generates a random number...Ch. 4 - Prob. 31PSCh. 4 - Code and run Program 4-16, "Top—down Development...Ch. 4 - Prob. 33PSCh. 4 - Prob. 34PSCh. 4 - Expand the calculator program, Program 4-15, to...Ch. 4 - Prob. 36PSCh. 4 - Write a function that receives a positive...Ch. 4 - Prob. 38PSCh. 4 - Prob. 39PSCh. 4 - Prepare a payroll earnings statement for the sales...Ch. 4 - Write a program that, given a beginning balance in...Ch. 4 - The formula for converting centigrade temperatures...Ch. 4 - Write a program that uses standard functions. The...Ch. 4 - Write a C program that creates customers' bills...
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
- Write the definition of a function that takes as input two decimal numbers and returns first number to the power of the second number plus second number to the power of the first number. (4)arrow_forwardWrite a program using function that takes in a Celsius degree as input, and outputs a Fahrenheit degree. For a user input Celsius value, the Fahrenheit formula is: Fahrenheit= Celsius*(9/5)+32 Output each floating-point value with one digit after the decimal point, which can be achieved as follows: print(f'{your_value1:.1f}) Ex: If the input is: 78 Then the output is: 172.4arrow_forwardWrite your own definition for the function absfun( ) which receives real number x as an argument and returns its absolute value (i.e. abs(x)=|x|). Use this function in a program that reads numbers from the keyboard and prints their absolute values. [Don’t use math library] Sample Run Enter x :-3 Output: abs(-3) = 3.00 in c languagearrow_forward
- 79. To find the decimal value of 1111, that is 15, we can use the function: a. int(1111,10) b. int(‘1111’,10) c. int(1111,2) d. int(‘1111’,2)arrow_forwardWrite a function to check if a given input number is a jumping number. A number is called jumpingnumberif all adjacent digits in it differ by 1. All single digits are considered as jumping numbers. Some examplesof jumping numbers are 0, 5, 10, 12, 78, 567, 101.arrow_forwardWrite a function encoding that takes a string and an integer as the parameters, and returns a new string, so that at each position, the two characters in the string and the new string are the integer number of positions away from each other in the ASCII character encoding table. Then swap the two half-strings. For example, encoding('ABCabc..10) should return the new string "WXY789". Please write this in Python3 language.arrow_forward
- Create a sum to(n) function in Python that returns the sum of all integer values up to and including n. Sum to(10), for example, would yield 55 as 1+2+3...+10.arrow_forwardc language Write a function which takes an integer and returns 1 if there are an odd number of ‘1’ bits 0 if there are an even number of ‘1’ bits Example, of x is 1010 in binary, it should return 0 because there are two 1's. 1110 should return 1 because there are three 1'sarrow_forwardWrite a C++ function that takes two integer inputs 'low' and 'high' and returns a random number that falls within this range.Use this function in a program to generate random numbers that fall within the following ranges: a) 0≤n≤3 b) 500≤n≤678 c) -3≤n≤12arrow_forward
- Write a function that would return single digit sum of a number. Ex. Given: 195 the function returns 6 -> 1+9+5=15 then 1+5=6 Given: 711 the function returns 9 -> 7+1+1=9arrow_forwardWrite a function that makes the base conversion. It takes two integers n and b as input (n >= 0 andb > 1, both in base 10) and expresses n in base b. For example, the decimal expansion of 345 inbase 10 is 345 = 3 × 102 + 4 × 101 + 5 × 100.Sample input: n = 12, b =2. Sample output: 1100Explanation: (12)10 = (1100)2arrow_forwardUsing javascript to write a function taking two numbers as arguments. Return true if the sum of any digit in num1 is equal to num2. (e.x. 100365, 8 => true, because 3 + 5 = 8)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
Computer Programming for Beginners | Functions, Parameters & Arguments | Ep24; Author: Programming With Avelx;https://www.youtube.com/watch?v=VXlh-qJpfw0;License: Standard YouTube License, CC-BY