How to form an array with the input values
Ältere Kommentare anzeigen
%How would i form an array if i had 5 inputs like this of random number
% displayed at the end.
clc,clear
x = 12;
num = 0;
for index = 1:5
y = input('Guess the number? ','s');
z = y + num;
if z >= 13
disp(' Too High! ')
elseif z <= 11
disp(' Too Low!')
else; z = x;
disp(' Correct! ')
break
end
end
1 Kommentar
Walter Roberson
am 30 Okt. 2020
What is it that is to be displayed at the end? The sequence of Too High / Too low messages for each of the 5 random numbers?
What should be output in the case where the person does not make a correct guess within 5 tries?
Is there a connection between the "5" being the number of random numbers to work with, and the "5" being the number of guesses that the user is permitted ?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!