Write a function count_odd that takes two arguments: low_bound and high_bound. The function counts how many odd values are there between the low_bound and the high_bound. Last it returns the number of odd numbers between these two values.
Show older comments
Here is what I have. All help is appreciated.
function count_odd(low_bound, high_bound)
% promt user to enter low_bound and high_bound
low_bound=input('Enter low bound: ')
high_bound=input('Enter high bound: ')
end
3 Comments
Adam
on 26 Jul 2018
You are passing low_bound and high_bound into the function so you shouldn't then be asking for them as input.
Since it is your question though you need to show a little more effort that that on the actual question at hand - i.e. counting odd values.
doc rem
doc sum
would both be helpful for doing that.
Layken McMeekin
on 26 Jul 2018
Adam
on 26 Jul 2018
The questions asks you to return it, not display it, so just calculate it in a variable and return that variable from the function.
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!