C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 5, Problem 5.8E

Show the value of x after each of the following statements is performed:

  1. x = fabs ( 7 . 5 ) ;
  2. x = floor ( 7 . 5 ) ;
  3. x = fabs ( 0.0 ) ;
  4. x = ceil ( 0.0 ) ;
  5. x = fabs ( 6 . 4 ) ;
  6. x = ceil ( 6 . 4 ) ;
  7. x = ceil ( fabs ( +  floor ( 5 . 5 ) ) ) ;

a)

Expert Solution
Check Mark
Program Plan Intro

To show the value of x after the given statement is performed.

Program Description Answer

The value of x is 7 .

Explanation of Solution

Given information:

  x = fabs(7.5);

Explanation:

The fabs() is the function that calculates the absolute value of the argument written within it. The absolute value of the number is the magnitude of the number irrespective of the sign. The statement x = fabs(7.5) calculates the values and assigns it to x.

Hence, the value of x is 7

b)

Expert Solution
Check Mark
Program Plan Intro

To show the value of x after the given statement is performed.

Program Description Answer

The value of x is 7 .

Explanation of Solution

Given information:

  x = floor(7.5);

Explanation:

The floor() is the function that calculates the value of the largest integer less than or equal to the argument written within it.

The statement x = floor(7.5); calculates the values and assigns it to x.

The largest integer less than or equal to 7.5 is 7.

Hence, the value of x is 7

c)

Expert Solution
Check Mark
Program Plan Intro

To show the value of x after the given statement is performed.

Program Description Answer

The value of x is 0 .

Explanation of Solution

Given information:

  x = fabs(0.0);

Explanation:

The fabs() is the function that calculates the absolute value of the argument written within it. The absolute value of the number is the magnitude of the number irrespective of the sign. The statement x = fabs(0.0); calculates the values and assigns it to x.

Hence, the value of x is 0

d)

Expert Solution
Check Mark
Program Plan Intro

To show the value of x after the given statement is performed.

Program Description Answer

The value of x is 0 .

Explanation of Solution

Given information:

  x = ceil(0.0);

Explanation:

The ceil() is the function that calculates the value of the smallest integer greater than or equal to the argument number written within it.

The statement x = ceil(0.0); calculates the values and assigns it to x.

The smallest integer greater than or equal to 0.0 is 0.

Hence, the value of x is 0

Expert Solution
Check Mark
Program Plan Intro

To show the value of x after the given statement is performed.

Program Description Answer

The value of x is 6 .

Explanation of Solution

Given information:

  x = fabs(6.4);

Explanation:

The fabs() is the function that calculates the absolute value of the argument written within it. The absolute value of the number is the magnitude of the number irrespective of the sign. The statement x = fabs(6.4); calculates the values and assigns it to x.

Hence, the value of x is 6

e)

Expert Solution
Check Mark
Program Plan Intro

To show the value of x after given statement is performed.

Program Description Answer

The value of x is 6 .

Explanation of Solution

Given information:

  x = ceil(6.4);

Explanation:

The ceil() is the function that calculates the value of the smallest integer greater than or equal to the argument number written within it.

The statement x = ceil(6.4); it calculates the values and assigns it to x.

The smallest integer greater than or equal to -6.4 is -6.

Hence, the value of x is 6

f)

Expert Solution
Check Mark
Program Plan Intro

To show the value of x after the given statement is performed.

Program Description Answer

The value of x is 14 .

Explanation of Solution

Given information:

  x = ceil(fabs(8+floor(5.5)));

Explanation:

The statement includes fabs() , ceil() and floor() functions.

The ceil() is the function that calculates the value of the smallest integer greater than or equal to the argument number written within it.

The fabs() is the function that calculates the absolute value of the argument written within it. The absolute value of the number is the magnitude of the number irrespective of the sign.

The floor() is the function that calculates the value of the largest integer less than or equal to the argument written within it.

On the basis of the above definitions solving the given statement as follows-

  x = ceil(fabs(8+floor(5.5)));x = ceil(fabs(86));x = ceil(fabs(14));x = ceil(14);x=14

Hence, the value of x is 14

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
04:54
Students have asked these similar questions
Answer the question fully and accurately by providing the required files(Java Code, Two output files and written answers to questions 1-3 in a word document)meaning question 1 to 3 also provide correct answers for those questions.(note: this quetion is not graded).
.NET Interactive Solving Sudoku using Grover's Algorithm We will now solve a simple problem using Grover's algorithm, for which we do not necessarily know the solution beforehand. Our problem is a 2x2 binary sudoku, which in our case has two simple rules: •No column may contain the same value twice •No row may contain the same value twice If we assign each square in our sudoku to a variable like so: 1 V V₁ V3 V2 we want our circuit to output a solution to this sudoku. Note that, while this approach of using Grover's algorithm to solve this problem is not practical (you can probably find the solution in your head!), the purpose of this example is to demonstrate the conversion of classical decision problems into oracles for Grover's algorithm. Turning the Problem into a Circuit We want to create an oracle that will help us solve this problem, and we will start by creating a circuit that identifies a correct solution, we simply need to create a classical function on a quantum circuit that…
.NET Interactive Solving Sudoku using Grover's Algorithm We will now solve a simple problem using Grover's algorithm, for which we do not necessarily know the solution beforehand. Our problem is a 2x2 binary sudoku, which in our case has two simple rules: •No column may contain the same value twice •No row may contain the same value twice If we assign each square in our sudoku to a variable like so: 1 V V₁ V3 V2 we want our circuit to output a solution to this sudoku. Note that, while this approach of using Grover's algorithm to solve this problem is not practical (you can probably find the solution in your head!), the purpose of this example is to demonstrate the conversion of classical decision problems into oracles for Grover's algorithm. Turning the Problem into a Circuit We want to create an oracle that will help us solve this problem, and we will start by creating a circuit that identifies a correct solution, we simply need to create a classical function on a quantum circuit that…

Chapter 5 Solutions

C How to Program (8th Edition)

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...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY