Write a function called isint to check whether an input numb

Write a function called \"isint\" to check whether an input number is an integer. The function should display a sentence of the form: \"22.5 is not an integer!\" or \"99 is an integer !\" if the inputs were respectively 22.5 and 99.

Solution

Following is the solution for checking a number is integer or real.

Function definition:

function [] = isInt(x)

if rem(x,1)==0
fprintf(\'%d is an integer! \ \', x);
else
fprintf(\'%f is not an integer! \ \', x);
end
end

Call to the function can written as:

function [] = isInt(x)

if rem(x,1)==0
fprintf(\'%d is an integer! \ \', x);
else
fprintf(\'%f is not an integer! \ \', x);
end
end

 Write a function called \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site