Computer Science: A Structured Programming Approach Using C, Third Edition
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.
Expert Solution & Answer
Book Icon
Chapter 4, Problem 23PS

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

Blurred answer
Students have asked these similar questions
a database with multiple tables from attributes as shown above that are in 3NF, showing PK, non-key attributes, and FK for each table? Assume the tables are already in 1NF. [Hint: 3 tables will result after deducing 1NF -> 2NF -> 3NF]
a database with multiple tables from attributes as shown above that are in 3NF, showing PK, non-key attributes, and FK for each table? Assume the tables are already in 1NF. [Hint: 3 tables will result after deducing 1NF -> 2NF -> 3NF]
If a new entity Order_Details is introduced, will it be a strong entity or weak entity? If it is a weak entity, then mention its type (ID or Non-ID, also Justify why)?

Chapter 4 Solutions

Computer Science: A Structured Programming Approach Using C, Third Edition

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
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
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage