I need help writing a function that checks if a number is even or odd in Matlab.
Mostra commenti meno recenti
Write a function that would decide whether a number is even or odd. The function will take input n and display on the command window either “even” or “odd”.
function [] = EvenOrOdd(n)
• note that the function EvenOrOdd does not have a return value.
• To display a string on the command window use disp(‘text’)
• The function Mod(X,Y) returns the modulus after dividing X by Y
this is my work:
x=input ('value');
if mod(x,2)
disp('odd')
else
disp('even')
end
Help me please?
2 Commenti
Walter Roberson
il 16 Nov 2013
What part were you hoping for assistance with?
The notes nearly give away the entire code.
Alnuaimi
il 16 Nov 2013
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Dates and Time in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!