function guess_letter % % Play a guessing game with the user. Pick a letter, then ask her % to guess it. Quit when she succeeds. % % this is the letter -- the user has to guess it letter = 'p'; finished = 0; while (finished == 0) % prompt the user, and put her result in the variable "guess" guess = input('I am thinking of a letter. Which is it? ', 's'); % now use "strcmp" to compare the guess and the actual letter if (strcmp(guess, letter) == 1) fprintf(1, 'yes, that is correct -- it was %s\n', letter); finished = 1; else fprintf(1, 'nope, that is not right\n'); end end