Hello, I'm trying to store my input into another variable while being called from another function.
function hiloTest()
gameOver = 0;
while gameOver == 0 [gameOver, guess] = showResults() endendfunction [gameOver, guess] = showResults()gameOver = false;ii = 46;%I want to store this [x] = inPut() function's input into variable named 'guess'
[x] = inPut() while (gameOver == 0) if (guess < ii) disp('Close, but you need to go a bit higher.'); [x] = inPut(); elseif (guess > ii) disp('Your guess is high. Please try again.'); [x] = inPut(); else disp('Right, you got it. Thank you for playing.'); gameOver = true; end endendfunction [x] = inPut() [x] = input('Please enter a number between 1 and 100: ');end
I still got lots to learn, please help. Thank you in advance 😀
Best Answer