a.
Explanation of Solution
 Given: The expression is floor (x*10+0.5)/10, where x is 3.5, 3.45, 3.76, 3.234, and 3.4567.
To find:Â The value of the expression, floor (x*10+0.5)/10, where x is 3.5, 3.45, 3.76, 3.234, and 3.4567.
Solution:
The output of the aforementioned statement, (x*10+0.5)/10, when:
x=3.5
The output of the aforementioned expression will evaluate to 3.500000. On substituting the value of x as 3.5, the expression will be evaluated. Then the function named ‘floor()’ is applied, which will return the largest double value which is smaller than or equal to integer x. The value it will return will be of type, double.
The following is the sample code:
The output of the above function will look like:
x=3.45
The output of the aforementioned expression will evaluate to 3.500000. On substituting the value of x as 3.45, the expression will be evaluated. Then the function named ‘floor()’ is applied, which will return the largest double value which is smaller than or equal to integer x. The value it will return will be of type, double.
The following is the sample code:
The output of the above function will look like:
x=3.76
The output of the aforementioned expression will evaluate to 3.800000. On substituting the value of x as 3.76, the expression will be evaluated. Then the function named ‘floor()’ is applied, which will return the largest double value which is smaller than or equal to integer x...
b.
Explanation of Solution
 Given: The expression is floor (x*100+0.5)/100 where x is 3.5, 3.45, 3.76, 3.234, and 3.4567.
To find:Â The value of the expression, floor (x*100+0.5)/100, where x is 3.5, 3.45, 3.76, 3.234, and 3.4567.
Solution:
The output of the aforementioned statement, (x*100+0.5)/100, when:
x=3.5
The output of the aforementioned expression will evaluate to 3.500000. On substituting the value of x as 3.5, the expression will be evaluated. Then the function named ‘floor()’ is applied, which will return the largest double value which is smaller than or equal to integer x. The value it will return will be of type, double.
The following is the sample code:
The output of the above function will look like:
x=3.45
The output of the aforementioned expression will evaluate to 3.450000. On substituting the value of x as 3.45, the expression will be evaluated. Then the function named ‘floor()’ is applied, which will return the largest double value which is smaller than or equal to integer x. The value it will return will be of type, double.
The following is the sample code:
The output of the above function will look like:
x=3.76
The output of the aforementioned expression will evaluate to 3.760000. On substituting the value of x as 3.76, the expression will be evaluated. Then the function named ‘floor()’ is applied, which will return the largest double value which is smaller than or equal to integer x...
c.
Explanation of Solution
 Given: The expression is floor (x*1000+0.5)/1000, where x is 3.5, 3.45, 3.76, 3.234, and 3.4567.
To find:Â The value of the expression, floor (x*1000+0.5)/1000, where x is 3.5, 3.45, 3.76, 3.234, and 3.4567.
Solution:
The output of the aforementioned statement, (x*1000+0.5)/1000, when:
x=3.5
The output of the aforementioned expression will evaluate to 3.500000. On substituting the value of x as 3.5, the expression will be evaluated. Then the function named ‘floor()’ is applied, which will return the largest double value which is smaller than or equal to integer x. The value it will return will be of type, double.
The following is the sample code:
The output of the above function will look like:
x=3.45
The output of the aforementioned expression will evaluate to 3.5. On substituting the value of x as 3.45, the expression will be evaluated. Then the function named ‘floor()’ is applied, which will return the largest double value which is smaller than or equal to integer x. The value it will return will be of type, double.
The following is the sample code:
The output of the above function will look like:
x=3.76
The output of the aforementioned expression will evaluate to 3.760000. On substituting the value of x as 3.76, the expression will be evaluated. Then the function named ‘floor()’ is applied, which will return the largest double value which is smaller than or equal to integer x...
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Computer Science: A Structured Programming Approach Using C, Third Edition
- 1a. It is known that x and n are integers, where x has a value of -1 and n has a value of 5. What is the valueof the following expression? !(++x || n) + 6 - (!n && n * (n < n)) I know this equals 6 but how do I work it out 1a .Compute the values of the following expressions if x is 1, y is 4 and z is 14. Assume thattrue relations have a value of 1 (I want to see how these problems are worked out) 1B. work out each of these. x+5<=z-(x||z)-y z/y%z-6<=!y x>=1&&y==3+y||z<14 x-!y-y<=z*z/6>yarrow_forwardQ6: The volume of oil stored in an underground 200-foot deep eylindrical tank is determined by measuring the distance from the top of the tank to the surface of the oil. Knowing this distance and the radius of the tank, the volume of oil in the tank can be determined by using this formula: volume = 7 radius (200- distance) Using this information, write a program that uses a function called volume to calculate the volume of oil in the tank.arrow_forwardEvaluate the following expressions, assume the following declarations: int x = 4 /3 * 2; int y = 9/ 2; int num = 6; num *= x + y; What is the value of the num after expression is evaluated?arrow_forward
- raph EECP1290: Computer Programming for Engineering Write a program to calculate the K value using if else condition If P value is more than 9 then K = M/2 – vP+C If P value is less than or equal to 9 then K = M/2 + /P +C I= Where C is a constant with value 1.7arrow_forward4. During each summer, John and Jessica grow vegetables in their backyard and buy seeds and fertilizer from a local nursery. The nursery carries different types of vegetable fertilizers in various bag sizes. When buying a particular fertilizer, they want to know the price of the fertilizer per pound and the cost of fertilizing per square foot. The following program prompts the user to enter the size of the fertilizer bag, in pounds, the cost of the bag, and the area, in square feet, that can be covered by the bag. The program should output the desired result. However, the program contains logic errors. Find and correct the logic errors so that the program works properly. // Logic errors. #include #include using namespace std; int main() { double costs double area; double bagsize; cout > bagsize; cout > cost; cout > area; cout << endl; cout << "The cost of the fertilizer per pound is: $" << bagsize / cost << endl; cout << "The cost of fertilizing per square foot is: $" << area / cost << endl; return 0; }arrow_forward(Civil eng.) Write an assignment statement to calculate the linear expansion in a steel beam as a function of temperature increase. The formula for linear expansion, l, is as follows: l=l0(1+(TfT0)) l0isthelengthofthebeamattemperatureT0.isthecoefficientoflinearexpansion.Tfisthefinaltemperatureofthebeam.arrow_forward
- (Misc. application) a. Write a program to reverse the digits of a positive integer number. For example, if the number 8735 is entered, the number displayed should be 5378. (Hint: Use a do statement and continuously strip off and display the number’s units digit. If the variable numinitially contains the number entered, the units digit is obtained as (num % 10). After a units digit is displayed, dividing the number by 10 sets up the number for the next iteration. Therefore, (873510)is5and(8735/10)is873. The do statement should continue as long as the remaining number is not 0.) b. Run the program written in Exercise 3a and verify the program by using appropriate test data.arrow_forwardProvide statements with combined assignment operators for the statements below: x = x + 5; y = y * 3; z = z - 8;arrow_forwardQ#4: Program the following.· Prompt user to input distance in Kilometers and display it in meters.· Input any number from user and generate its square e.g. square of 8 is 64· Input any number from user and generate its cube e.g. cube of 8 is 512· Input a 4 digit number in any integer type variable and sum all the four digits, e.g. int a =3487,result = 22· Generate the table for a number input by the user.· For the following equation 3x 4 + 4x 3 + x 2 + 7x + 9, substitute the user provided value of x andgenerate the result. Language Carrow_forward
- PROBLEM: Write a program that prompts the user to input the amount of money that an ATM machine will dispense and then show the breakdown of how many 1000, 500, and 100 peso bill/s are dispensed. The program must display the amount then prompt the user if the transaction will continue or not by choosing between Y (for Yes) and N (for No). If an invalid character is entered, it must display that the user entered an invalid character. The program must also display that the maximum allowable amount is 10,000 and the minimum allowable amount is 100. If the entered amount is greater than 10,000 or less than 100, an error notification must be displayed. Moreover, the entered amount must be exactly divisible by 100. SPECIFICATIONS: - You may only use the codes that we studied under our lectures All lines of codes should have a comment. - Save your cpp file as Surname - PE (Example: Pangaliman - PE.cpp) TEST CASES: If a user inputs an amount less than or equal to 10,000: REMINDER: Maximum…arrow_forwardPROBLEM:Write a program that prompts the user to input the amount of money that an ATM machine will dispense and then show the breakdown of how many 1000, 500, and 100 peso bill/s are dispensed. The program must display the amount then prompt the user if the transaction will continue or not by choosing between Y (for Yes) and N (for No). If an invalid character is entered, it must display that the user entered an invalid character. The program must also display that the maximum allowable amount is 10,000 and the minimum allowable amount is 100. If the entered amount is greater than 10,000 or less than 100, an error notification must be displayed. Moreover, the entered amount must be exactly divisible by 100. TEST CASES: If a user inputs an amount less than or equal to 10,000: REMINDER: Maximum amount must only be 10,000 and the minimum amount must not be less than 100 Enter Amount to dispense: 4900The Amount of money you entered is 4900.Do you want to continue your transaction?Enter…arrow_forwardQ3: By using Select-Case; write a program to calculate (BMI body mass index) (11 M) weight BMI = hieght And print the result as follows Underweight = 30arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ 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