Develop a function odd_even that determines whether a number is odd or even. It must have the following features:
Develop a function odd_even that determines whether a number is odd or even. It must have the following features:
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
![I. Objectives
1. To learn how to use conditional statements.
2. To learn how to translate a condition into an appropriate code.
II. Instructions
Develop a function odd_even that determines whether a number is odd or even. It must have the following features:
▪ It must take in a scalar value x.
▪ Its output is a character value y.
▪ If the value is odd, set the output equal to odd, otherwise, set it to even.
▪ If the value of x provided by the user is not scalar, set the output equal to non-scalar.
▪
If the value of x provided by the user is not a whole number, round it down to the nearest whole number, then proceed in determining whether it is odd or even.
Function Ⓒ
1 function y = odd_even(x)
Code to call your function >
1| oe1 = odd_even (7)
2oe2 = odd_even (8)
C Reset
MATLAB Documentation
C Reset
▶ Run Function ?](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe51ed901-fb62-4f78-abe9-9a3c28ee810c%2F56d212fe-e111-4516-b615-eeb682ebf6fd%2Fu0mqbqk_processed.png&w=3840&q=75)
Transcribed Image Text:I. Objectives
1. To learn how to use conditional statements.
2. To learn how to translate a condition into an appropriate code.
II. Instructions
Develop a function odd_even that determines whether a number is odd or even. It must have the following features:
▪ It must take in a scalar value x.
▪ Its output is a character value y.
▪ If the value is odd, set the output equal to odd, otherwise, set it to even.
▪ If the value of x provided by the user is not scalar, set the output equal to non-scalar.
▪
If the value of x provided by the user is not a whole number, round it down to the nearest whole number, then proceed in determining whether it is odd or even.
Function Ⓒ
1 function y = odd_even(x)
Code to call your function >
1| oe1 = odd_even (7)
2oe2 = odd_even (8)
C Reset
MATLAB Documentation
C Reset
▶ Run Function ?
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question
![Can the function determine if a whole number is odd?
Can the function determine if a whole number is even?
Can the function determine if the value is non-scalar?
Variable y must be of data type char. It is currently of type string. Check where the variable is assigned a value.
Is the input rounded down to the nearest whole number?
Variable y has an incorrect value.](https://content.bartleby.com/qna-images/question/e51ed901-fb62-4f78-abe9-9a3c28ee810c/61789989-16ff-497f-b7a9-c1dd1d7e9954/vss62w4_thumbnail.png)
Transcribed Image Text:Can the function determine if a whole number is odd?
Can the function determine if a whole number is even?
Can the function determine if the value is non-scalar?
Variable y must be of data type char. It is currently of type string. Check where the variable is assigned a value.
Is the input rounded down to the nearest whole number?
Variable y has an incorrect value.
Solution
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY