a)
function bool = isInteger(N) bool = (N == round(N)); end
b)
function bool = isEven(N) bool = (helTall(N/2)); % eller bool = (mod(N,2) == 0); end
c)
function bool = isPositive(N) bool = (N >= 0); end
d)
N = input('Oppgi et tall: '); if isInteger(N) disp('Tallet er et heltall'); if isEven(N) disp('Tallet er et partall'); else disp('Tallet er et oddetall'); end else disp('Tallet er ikke et heltall'); end if isPositive(N) disp('Tallet er positivt'); else disp('Tallet er negativt'); end
e)
function bool = compare(A, B) bool = (~(A > B) && ~(A < B)); end % Mange veier til rom!