% ---------------------------------------------------------------------- % A simple program to demonstrate IF-THEN-ELSE; test the sign of a given number % The general syntax is: % if condition1 % statements1 % elseif condition2 % statements2 % elseif condition3 % statements3 % more elseif testing % statements4 % else % statements5 % endif % Combine into one line % if conditions, statements1; end % The "elseif" part and the "else" part are optional. % Programming note: naming this file as if-then.m conflicts with MATLAB. % % Instructor: Nam Sun Wang % ---------------------------------------------------------------------- % Start fresh ---------------------------------------------------------- clear all % Program header ------------------------------------------------------- disp ('This program simply tests the sign of a given integer') % Input an integer ----------------------------------------------------- i=input('input an integer: '); % Test the sign of the integer if ( i == 0 ) disp('You have entered a zero.') elseif ( i < 0 ) disp('You have entered a negative integer.') else disp ('You have entered a positive integer.') end