question7 ece

mail@pastecode.io avatar
unknown
plain_text
2 years ago
837 B
2
Indexable
Never
function q7 = question7(a)
if (a == 0)
    disp("given number equals to zero")
    if (mod(a,2) == 1)
        disp("given number is odd")
    else
        disp("given number is even")
    end
    if (isprime(a))
        disp("given number is prime")
    else
        disp("given number is not prime")
    end
elseif (a > 0)
    disp("given number is positive")
    if (mod(a,2) == 1)
        disp("given number is odd")
    else
        disp("given number is even")
    end
    if (isprime(a))
        disp("given number is prime")
    else
        disp("given number is not prime")
    end
elseif (a < 0)
    disp("given number is negative")
    if (mod(a,2) == 1)
        disp("given number is odd")
    else
        disp("given number is even")
    end
    disp("negative numbers cannot be prime, given number is not prime")
end
end