Pascal · lesson 6 of 30 · First stepsAsk the user
ReadLn reads a line of text, or several numbers on one line.
06-input.pas Download 06-input.pas
program Input;
var
Name: string;
Disks, Size: Integer;
begin
Write('Your name: ');
ReadLn(Name);
Write('Disks and TB in each: ');
ReadLn(Disks, Size);
WriteLn('Hello, ', Name);
WriteLn('Together the disks have ', Disks * Size, ' TB');
end.
Terminal
$ ./06-input
Your name: Ann Example
Disks and TB in each: 4 8
Hello, Ann Example
Together the disks have 32 TBExercise
Ask for a year and print how old a disk from that year is.