MATLAB has a function called round that rounds a number to the nearest integer. As an example, round (4.5) is 5 and round (4.4) is 4. Write a program that calculates the ceiling and floor of a number using the round function. The ceiling rounds towards o and the floor rounds towards -0o. By hand, draw a flow chart showing what your program will do similar to what we have done in class. Find the ceiling and floor of (а) -5.3 (b) 9.5 (c) 3.49 (d) -6 Solution: (a) ceil: -5, floor: -6 (b) ceil: 10, floor: 9 (c) ceil: 4, floor: 3 (d) ceil: -6, floor: -6 Note: DO NOT use the built-in ceiling and floor functions that MATLAB has.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question
MATLAB has a function called round that rounds a number to the nearest integer. As an
example, round (4.5) is 5 and round(4.4) is 4. Write a program that calculates the ceiling
and floor of a number using the round function. The ceiling rounds towards oo and the
floor rounds towards -0o. By hand, draw a flow chart showing what your program will
do similar to what we have done in class. Find the ceiling and floor of
(а) -5.3
(b) 9.5
(c) 3.49
(d) -6
Solution: (a) ceil: -5, floor: -6 (b) ceil: 10, floor: 9 (c) ceil: 4, floor: 3 (d) ceil: -6, floor: -6
Note: DO NOT use the built-in ceiling and floor functions that MATLAB has.
Transcribed Image Text:MATLAB has a function called round that rounds a number to the nearest integer. As an example, round (4.5) is 5 and round(4.4) is 4. Write a program that calculates the ceiling and floor of a number using the round function. The ceiling rounds towards oo and the floor rounds towards -0o. By hand, draw a flow chart showing what your program will do similar to what we have done in class. Find the ceiling and floor of (а) -5.3 (b) 9.5 (c) 3.49 (d) -6 Solution: (a) ceil: -5, floor: -6 (b) ceil: 10, floor: 9 (c) ceil: 4, floor: 3 (d) ceil: -6, floor: -6 Note: DO NOT use the built-in ceiling and floor functions that MATLAB has.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning