So I'm trying to write a script that will ask the user to input a number between 100 and 200, inclusive. The program will check the actual user input. If the user input is not between 100 and 200, the program will keep asking for the input until the user provides a correct one. Then the program will print out the number. I have most of it working but it keeps running an error message that says
>> checkinput Index exceeds array bounds.
Error in checkinput (line 4) input=input('Enter a number between 100 and 200:');
My code is below but I'm a little lost on where I messed up.
% code
%this script will check to make sure user input is bw 100 and 200
%and print the input
input=input('Enter a number between 100 and 200:');% if loop execution
if(input>=100 && input<=200) fprintf('Value of Number: %d\n', input);else fprintf('Error! Must enter a number between 100 and 200.\n');end
Best Answer