...
Code Block | ||
---|---|---|
| ||
function resultatbool = helTall(N) resultatbool = (N == round(N)); end |
b)
Code Block | ||
---|---|---|
| ||
function resultatbool = parTall(N) resultatbool = (helTall(N/2)); % eller resultatbool = (mod(N,2) == 0); end |
c)
Code Block | ||
---|---|---|
| ||
function resultatbool = positivtTall(N) resultatbool = (N >= 0); end |
d)
Code Block | ||
---|---|---|
| ||
N = input('Oppgi et tall: '); if helTall(N) disp('Tallet er et heltall'); if parTall(N) disp('Tallet er et partall'); else disp('Tallet er et oddetall'); end else disp('Tallet er ikke et heltall'); end if positivtTall(N) disp('Tallet er positivt'); else disp('Tallet er negativt'); end |
...
Code Block | ||
---|---|---|
| ||
function resultatbool = sammenlikne(A, B) resultatbool = (~(A > B) && ~(A < B)); end |