What I want to do is read the characters in succession and count the number of characters in uppercase, lower case, numbers, and space. (we're told not to use strings).
My question is, why is this code not working? isn't it supposed to read the 1st character and then read the 2nd character until the last character of the input?
How can I make a loop that reads the 1st character in the input then read the character after that and so on...when it sees the end of line it should stop the loop.
program Contadordecaracteres;
VAR
minusculas,mayusculas,numeros,espacios:integer;
c:char;
begin
minusculas:= 0;
mayusculas:= 0;
numeros:= 0;
espacios:= 0;
writeln('Escriba algo');
while not EoLn do
begin
read(c);
case c of
' ': espacios:= espacios+1;
'0'..'9': numeros:= numeros+1;
'A'..'Z': mayusculas:= mayusculas+1;
'a'..'z': minusculas:= minusculas+1;
end; //end of case
end; // end of while
writeln('Mayusculas: ', mayusculas);
writeln('Minusculas: ', minusculas);
writeln('Numeros: ', numeros);
writeln('Espacios: ', espacios);
readln;
end.
text fileinto a string variable than to read the input a character at a time from the keyboard. This will instroduce you to string-manipulation, which is a basic required skill. Google yourself a tutorial that suits your level. - MartynA