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
Question
Chapter 4, Problem 38PS
Program Plan Intro
To create a program that reads a floating-point value and prints the floor, rounded , and ceiling value.
Program Plan:
The program should be written in C
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
a. Write a function named countDigits that accepts a positive integer as its
parameter and returns the number of digits in that number.
For example, the number 8546587 has seven digits, so the call
countDigits(8546587) should return 7.
You may assume that the value passed to your method is non-negative.
b. Write a program to input an integer n and call the above function in part a if n
is positive, else give 'Value must be Positive' message. Inputting will stop when 0
is entered.
Modify the program so that it does the following:
Performs a function that gets the area of a rectangle. The function must receive two parameters (decimal numbers) that represent the base and height of the rectangle and must return the calculated value (decimal number).
Perform a second function that obtains the total area of a rectangular prism with a rectangular base. The total area of such a prism is equal to the sum of the areas of each of its faces. It uses calls to the previous function for this calculation.
Call this last function in the main with user data.
Execution example
Give me the base: 21.3
Give me the height: 10
Give me the depth: 2.0
The total area of the prism is: 551.2
Write a function that takes a positive integer num and calculates how many dots exist in a
pentagonal shape around the center dot on the Nth iteration.
In the image below you can see the first iteration is only a single dot. On the second, there
are 6 dots. On the third, there are 16 dots, and on the fourth there are 31 dots.
Return the number of dots that exist in the whole pentagon on the Nth iteration.
Examples
pentagonal (1) → 1
pentagonal (2) <-6
pentagonal (3) - 16
pentagonal (8) → 141
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 a function averageDigits that computes the average of the digits of a 3-digit positive number in the range [100,999), Use the following function prototype: double averageDigits(int); For example, averageDigits(936) returns 6.0 ((9+3+6)/3). Write a test program that prompts the user to enter a 3-digit number, call the function averageDigits and print the result in the main program. The process is repeated if the user enters y to continue.arrow_forwardWrite another version of the checkeven function. This version receives 3 integer variables and returns true if all three numbers are even. Otherwise, the function returns false. Write the statements to read in three numbers and call the checkeven function. Then print YES if all three numbers were even, or print NO if they were not all even.arrow_forwardMake a function that determines if a triangle is equilateral, scalene, or isosceles given the length of the sides of the triangle. In the main function, prompt the user three times to input three numbers using the prompt()function. These three numbers are the measurements of the length of the sides of the triangle. Make sure that the user is typing numbers. Use the isNaN() function to check. To implement this, you can declare three variables and the value for each variable is a prompt for the user. Refer to the sample below: var a = prompt(); var b = prompt(); var c = prompt(); Create a function determineTriangle(a, b, c) that accepts the three numbers from the user as input. The output of the determineTriangle(a, b, c) function is the type of the triangle. Use if..else statements for this feature. If all three sides of the triangle are equal, then output “The triangle is EQUILATERAL.” If only two sides are equal, output “The triangle is ISOSCELES,” else, output “The triangle is…arrow_forward
- (Numerical) Using the srand() and rand() C++ library functions, fill an array of 1000 floating-point numbers with random numbers that have been scaled to the range 1 to 100. Then determine and display the number of random numbers having values between 1 and 50 and the number having values greater than 50. What do you expect the output counts to be?arrow_forwardComplete the function that calculates the sum of the first n+1 terms of the geometric series a, ar, ar² ar³, art Note that the series begins with a and the last term is ar", in total there are n+1 terms. # complete the function given the variables a,r,n and return the value as series_sum. def sum geometric_series (a,r,n): # YOUR CODE HERE return series_sum ... arr print (sum_geometric_series (4.0, 5, 10))arrow_forwardA company wants to transmit data over the telephone but is concerned that its phones may b tapped. It has asked you to write a program that will encrypt the data so that it may be transmitted more securely. All the data transmitted is 4 digit integers. Your program should read a four digit integer entered by the user and calls a function encrypt which takes four digits as arguments and encrypt it as follows . Replace each digit with the result of adding 4 to the digit and getting the remainder after dividing the new value by 10. . Calls another function swap which swaps the first digit with the third, and second digit with the fourth using pass by reference. Then it prints the encrypted integer.arrow_forward
- USING C++ A pedometer treats walking 1 step as walking 2.5 feet. Define a function named FeetToSteps that takes a double as a parameter, representing the number of feet walked, and returns an integer that represents the number of steps walked. Then, write a main program that reads the number of feet walked as an input, calls the function FeetToSteps() with the input as an argument, and outputs the number of steps. Use floating-point arithmetic to perform the conversion. Ex: If the input is: 150.5 the output is: 60 The program must define and call a function:int FeetToSteps (double userFeet)arrow_forwardIf a year has the digit 7 OR the digit 4 in it, then it is called a “Beautiful year”. For example, 2017, 2014, and 2072 are all beautiful years. If the year has BOTH 4 and 7 in it, then it's an “Amazing year”. For example, the years 2047 and 2074 are amazing years. All other years are “Ugly years”. You need to write a function that takes a year as an argument and return it's type. Then, finally print the returned values in the function call. ================================================ Sample Function Call 1: function_name(2470) Sample Output 1: Amazing year ================================================ Sample Function Call 2: function_name(2170) Sample Output 2: Beautiful year ================================================ Sample Function Call 3: function_name(2021) Sample Output 3: Ugly yeararrow_forwardWrite a program that works with fractions. Your program should be able to add,subtract, multiply, and divide two fractions. Write a separate function for addition,subtraction, multiplication and division. Specifically, your program must request two fractions from the user, getting the numerator and denominator separately for each fraction, and the operation to perform (add, subtract, multiply, or divide).Your program will then compute the resulting fraction, keeping the numerator and denominator separate, and output the result.arrow_forward
- A pedometer treats walking 1 step as walking 2.5 feet. Define a function named feet_to_steps that takes a float as a parameter, representing the number of feet walked, and returns an integer that represents the number of steps walked. Then, write a main program that reads the number of feet walked as an input, calls function feet_to_steps with the input as an argument, and outputs the number of steps as an integer. Use floating-point arithmetic to perform the conversion. Ex: If the input is: 150.5 the output is: 60 The program must define and call the following function: def feet_to_steps (user_feet) 461710.3116374.qx3zqy7 LAB ACTIVITY 7.10.1: LAB: Step counter 1 # Define your function here 3 if __name_ 4 '__main__': #Type your code here. main.py 0/10 Load default template...arrow_forwardWrite the following function to draw a regular polygon:def drawPolygon(x = 0, y = 0, radius = 50, numberOfSides = 3):The polygon is centered at (x, y) with a specified radius for the bounding circle for the polygon and the number of sides. Write a test program that displays a triangle, square, pentagon, hexagon, heptagon, and octagon, as shown in Figure 6.12a.arrow_forwardgood stat ofl them ii days. You need to upload your solutions in a single python file (assl.py) to the link on MS Teams. Part 1 Add this comment: # Ass 1: Part 1 Write a program that declares a function called draw Star which receives an integer value as a parameter, and draws a number of stars equal to the received integer. Samplel: Please enter the number of stars: 5 The shape is: **** Sample2: Please enter the number of stars: 3 The shape 15 *** Part 2 Add this comment: Ass 1: Part 2 Write a program that summation of even ni "nd M then prints the 3.9 nclud d if were even of 3arrow_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
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