Char Variables

A single character (letter, symbol or digit) may be stored in a variable of type char. Two or more char variables may be concatenated to form a string.

program CharVariables;
{$APPTYPE CONSOLE}
var
  Char1, Char2  : char;
  Initials : string;
begin
  write('Please enter the initial of your first name ');
  readln(Char1);
  write('Please enter the initial of your last name ');
  readln(Char2);
  Initials := Char1 + Char2;
  writeln('Your initials are ', Initials, '.');
  readln;
end.
Features introduced:
  • Char variables
  • Use of the operator + to concatenate chars.
Programming - a skill for life!

The various types of constants and variables and how to use them