October 9, 2020•3 min read

Output with Write and Writeln in Pascal

Output matters in programming, and not only there: every process is judged by what it produces. This is how Pascal puts text on the console.

Read in Indonesian

In this tutorial we'll cover the output system with write and writeln in Pascal. After getting our fill of the hello world program in earlier tutorials, it's time for a new one :D

The output system is very important in programming. Not only in programming, in fact: everything is oriented toward output.

Output matters because it's one of the measures of whether what we did succeeded or failed. Yeah, just one of them. Plenty of other things measure success too.

In programming, output comes in many forms: to the console, to a file, to a database, and so on. In this tutorial we'll stick to console output.

For anyone who doesn't know, "console" is my name for the black screen that appears when you run a Pascal program.

Pascal has 2 commands for console output: write and writeln. What's the difference? What is each one for? When should you use which? Let's get into it.

The writeln Command in Pascal

writeln is short for Write Line. The command writes output on one line, then moves to the next line.

Confused? Let's practice. Open your Free Pascal and type the following code.

PASCAL
program output;
uses crt;
begin
  clrscr;
  writeln('ini Budi');
  writeln('Budi sedang belajar Pascal');
  writeln('Budi mampir ke invasikode.com');
  readln;
end.

When you finish typing, save and run that Pascal code. Once the program executes, the console shows three lines of text, one under the other.

📷 Illustration: the console window printing three separate lines of text thanks to the writeln command.

From that output you can see the console prints the sentences inside the parentheses, one after another.

Every word or sentence you want to print as output must sit between quote marks ('). Just try deleting those quotes and running the program. An error will come out.

So what's the difference between writeln and write? Let's cover write as well.

The write Command in Pascal

The write command is basically the same as writeln. The only difference is the new line it adds.

With writeln the output ends up on many lines. With write the output stays on a single line.

Just try changing writeln in the code above into write.

PASCAL
program output;
uses crt;
begin
  clrscr;
  write('ini Budi');
  write('Budi sedang belajar Pascal');
  write('Budi mampir ke invasikode.com');
  readln;
end.

If you're done, run it. This time the output merges into one horizontal line, with no line breaks.

📷 Illustration: the console window showing all three sentences joined on one line after the switch to write.

Just like writeln, the sentence inside the parentheses prints as output. But with write every sentence sits on one line, which makes it a little harder to read.

The write command exists to print output without moving to the next line. That's very useful when we use it as a label for input, which we'll cover next.

Closing

If you want to try other output, just change the sentence inside the parentheses in write and writeln. Adding more output lines works too hehe.

That's all for this tutorial, hope it helps :D. Next we'll learn about Variables, Constants, and Data Types in Pascal.

Get better at shipping code.

Join the other developers getting tech updates, tips, and relaxed tutorials in their inbox every week.

Stay in the loop

Tech updates, coding tips, and relaxed insights straight to your inbox every week.

No spam. Unsubscribe anytime.

Read next

See all

For developers who learn by struggling

© 2026 Inva.dev.