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

% matab code

function result = isInt(number)
  
    if isreal(number) && rem(number,1)==0
        fprintf(\"%d is an integer!\ \", number);
    else
        fprintf(\"%f is not an integer!\ \", number);
    end
end


number = input(\'Enter the number: \');
isInt(number);

%{
output:

Enter a number: 99
99 is an integer!
%}

 Write a function called \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site