Anonymous user
Keyboard input/Obtain a Y or N response: Difference between revisions
Keyboard input/Obtain a Y or N response (view source)
Revision as of 22:57, 26 April 2012
, 12 years ago→{{header|Pascal}}: add example
(→{{header|Pascal}}: add example) |
|||
Line 264:
MESSAGE lanswer VIEW-AS ALERT-BOX.</lang>
=={{header|Pascal}}==
{{works with|Free_Pascal}}
{{libheader|CRT}}
<lang pascal>Program ObtainYN;
uses
crt;
var
key: char;
begin
write('Your answer? (Y/N): ');
repeat
key := readkey;
until (key in ['Y', 'y', 'N', 'n']);
writeln;
writeln ('Your answer was: ', key);
end.</lang>
Output:
<pre>% ./ObtainYN
Your answer? (Y/N):
Your answer was: y
</pre>
=={{header|Perl}}==
|